Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on newer Node.js and on Windows. #1

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function fail (err) {
}

function basePath (file) {
return path.relative(SUITE_DIR, file)
return path.relative(SUITE_DIR, file).replace(/\\/g, '/')
}

function writeManifest (fileList) {
Expand All @@ -40,7 +40,7 @@ function writeManifest (fileList) {
}
code.push(']')
var codeStr = code.join('')
fs.writeFile('./node-test/index.js', codeStr)
fs.writeFileSync('./node-test/index.js', codeStr)
console.log('done!')
}

Expand Down Expand Up @@ -70,7 +70,7 @@ function build () {
if (str) {
var fileName = result.caseName
fileList.push(fileName)
fs.writeFile(path.join(TEST_DIR, fileName) + '.js', str)
fs.writeFileSync(path.join(TEST_DIR, fileName) + '.js', str)
}
decCount()
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compile-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function generateShell (suiteDir, data) {
'ENVIRONMENT.scriptList=', JSON.stringify(data.shaders), ';',
'ENVIRONMENT.canvasList=', JSON.stringify(data.canvas), '.map(function(opts){return _canvasShim(ENVIRONMENT,opts);});',
'ENVIRONMENT.RESOURCES=_RESOURCES;',
'ENVIRONMENT.BASEPATH="', path.relative(suiteDir, data.directory), '";',
'ENVIRONMENT.BASEPATH="', path.relative(suiteDir, data.directory).replace(/\\/g, '/'), '";',
'var document=ENVIRONMENT.document;',
'var window=ENVIRONMENT.window;',
'var Image=_imageShim;',
Expand Down
2 changes: 1 addition & 1 deletion lib/parse-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function parseTestCase (VERSION, file, cb) {
tr.selectAll('script', function (elem) {
var src = elem.getAttribute('src')
if (src) {
var relpath = path.relative(root, path.resolve(path.join(dirname, src)))
var relpath = path.relative(root, path.resolve(path.join(dirname, src))).replace(/\\/g, '/')
srcTags.push(relpath)
} else {
var type = elem.getAttribute('type') || elem.getAttribute('language')
Expand Down
3 changes: 2 additions & 1 deletion lib/scan-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = globTestCases

var path = require('path')
var fs = require('fs')
var os = require('os')

function globTestCases (VERSION, cb) {
var rootFile = path.join(__dirname, '../conformance-suites', VERSION, '00_test_list.txt')
Expand Down Expand Up @@ -40,7 +41,7 @@ function globTestCases (VERSION, cb) {
return
}
var root = path.dirname(list)
var lines = data.toString().split('\n')
var lines = data.toString().split(os.EOL)
for (var i = 0; i < lines.length; ++i) {
var toks = lines[i].split(' ')
if (toks.length === 0 || toks[0].indexOf('#') === 0) {
Expand Down
4 changes: 3 additions & 1 deletion lib/shims/canvas-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ proto.getContext = function (type, options) {
this._width,
this._height,
options)
gl.canvas = this
if (!Object.hasOwn(gl, 'canvas')) {
gl.canvas = this
}
this._gl = gl
}
if (type === 'webgl' || type === 'experimental-webgl') {
Expand Down
12 changes: 9 additions & 3 deletions lib/shims/webgl-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,9 @@ var create3DContext = function(opt_canvas, opt_attributes) {
width = canvasList[i].width || 500
height = canvasList[i].height || 500
var ctx = ENVIRONMENT.createContext(width, height, opt_attributes)
ctx.canvas = canvasList[i]
if (!Object.hasOwn(ctx, 'canvas')) {
ctx.canvas = canvasList[i]
}
ctx.canvas._gl = ctx
canvas = ctx.canvas
return ctx
Expand All @@ -1073,15 +1075,19 @@ var create3DContext = function(opt_canvas, opt_attributes) {
width = opt_canvas.width || 512
height = opt_canvas.height || 512
var ctx = ENVIRONMENT.createContext(width, height, opt_attributes)
ctx.canvas = opt_canvas
if (!Object.hasOwn(ctx, 'canvas')) {
ctx.canvas = opt_canvas
}
ctx.canvas._gl = ctx
canvas = ctx.canvas
return ctx
}
}
var ctx = ENVIRONMENT.createContext(width, height, opt_attributes)
canvas = document.createElement("canvas")
ctx.canvas = canvas
if (!Object.hasOwn(ctx, 'canvas')) {
ctx.canvas = canvas
}
ctx.canvas._gl = ctx
return ctx
}
Expand Down