diff --git a/src/common/wasi/wasishim.ts b/src/common/wasi/wasishim.ts index 6b03498d..460233f5 100644 --- a/src/common/wasi/wasishim.ts +++ b/src/common/wasi/wasishim.ts @@ -440,9 +440,9 @@ export class WASIRunner { } else return WASIErrors.INVAL; } } else { - if (file == null) return WASIErrors.NOSYS; + if (file == null) return WASIErrors.NOENT; if (o_flags & FDOpenFlags.DIRECTORY) { // check type - if (file.type !== FDType.DIRECTORY) return WASIErrors.NOSYS; + if (file.type !== FDType.DIRECTORY) return WASIErrors.NOTDIR; } if (o_flags & FDOpenFlags.EXCL) return WASIErrors.INVAL; // already exists if (o_flags & FDOpenFlags.TRUNC) { // truncate diff --git a/src/worker/tools/urust.ts b/src/worker/tools/urust.ts index c9e24635..a30aa35b 100644 --- a/src/worker/tools/urust.ts +++ b/src/worker/tools/urust.ts @@ -27,8 +27,9 @@ export function compileUrust(step: BuildStep): BuildStepResult { wasi.initSync(wasiModule); populateWASIFiles(wasi, step); const args = ['urust', 'build', step.path, '--platform', platform, '--emit', 'bin', '-o', binpath, - '-Ob', '-fno-bounds-checks', + '-O1', '-fno-bounds-checks', '-Wall', + '--auto-mod', '--debug-out', dbgpath, '--error-format', 'json']; args.push.apply(args, extraArgsFor('urust', step.params && step.params.buildArgs)); wasi.setArgs(args); diff --git a/test/unit/testurust.ts b/test/unit/testurust.ts index cbfa303b..563fb15c 100644 --- a/test/unit/testurust.ts +++ b/test/unit/testurust.ts @@ -54,7 +54,7 @@ describe('urust tool', function () { assert.strictEqual(urustPlatformName('c64'), 'c64'); assert.strictEqual(urustPlatformName('atari8-800xl'), 'atari8'); assert.strictEqual(urustPlatformName('vcs'), 'vcs'); - assert.strictEqual(urustPlatformName('apple2'), undefined); + assert.strictEqual(urustPlatformName('apple2'), 'apple2'); }); it('parses JSON diagnostics; end column only on a single line', function () { diff --git a/test/unit/testwasishim.ts b/test/unit/testwasishim.ts index 25983e7e..9d4d24f8 100644 --- a/test/unit/testwasishim.ts +++ b/test/unit/testwasishim.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import { WASIRunner, WASIMemoryFilesystem, WASIErrors, normalizeWASIPath } from "../../src/common/wasi/wasishim"; +import { WASIRunner, WASIMemoryFilesystem, WASIErrors, FDOpenFlags, normalizeWASIPath } from "../../src/common/wasi/wasishim"; import * as fs from "fs"; import { loadWASIFilesystemZip, unzipWASIFilesystem } from "../../src/worker/wasiutils"; import { parseOscar64Listing, parseOscar64Lbl, parseOscar64Map } from "../../src/worker/tools/oscar64parse"; @@ -168,6 +168,12 @@ describe('WASIMemoryFilesystem path handling', function () { assert.strictEqual(normalizeWASIPath('.'), '.'); assert.strictEqual(normalizeWASIPath('/'), '/'); }); + it('reports a missing file as NOENT, not NOSYS', function () { + const wasi = new WASIRunner(); + assert.strictEqual(wasi.openFile('./missing.bin', 0), WASIErrors.NOENT); + wasi.fs.putFile('./plain.bin', 'x'); + assert.strictEqual(wasi.openFile('./plain.bin', FDOpenFlags.DIRECTORY), WASIErrors.NOTDIR); + }); it('finds files written with a different leading ./ depth', function () { const fsys = new WASIMemoryFilesystem(); fsys.putFile('././main.map', 'map');