Skip to content

Commit c945c13

Browse files
fix args and env for test suites
1 parent 62c12ac commit c945c13

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/features/environ.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function useEnviron(options: WASIOptions, abi: WASIAbi, memoryView: () =>
1515
const value = options.env[key];
1616
view.setUint32(offsetOffset, bufferOffset, true);
1717
offsetOffset += 4;
18-
bufferOffset += abi.writeString(view, `${key}=${value}\0`, environBuf);
18+
bufferOffset += abi.writeString(view, `${key}=${value}\0`, bufferOffset);
1919
}
2020
return WASIAbi.WASI_ESUCCESS;
2121
},

test/wasi-test-suite/harness.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { WASI, useEnviron, useArgs, useClock, useProc, useRandom, useStdio } fro
22
import { WASIAbi } from "../../src/abi";
33
import { existsSync } from "fs";
44
import { readFile } from "fs/promises";
5+
import { basename } from "path"
56

67
export async function runTest(filePath: string) {
78
let stdout = "";
@@ -39,8 +40,16 @@ export async function runTest(filePath: string) {
3940
return { ...acc, [components[0]]: components.slice(1).join("=") };
4041
}, {});
4142
})()
43+
const args = await (async () => {
44+
const path = filePath.replace(/\.wasm$/, ".arg");
45+
if (!existsSync(path)) {
46+
return [];
47+
}
48+
const data = await readFile(path, "utf8");
49+
return data.split("\n").map(line => line.trim()).filter(line => line.length > 0);
50+
})()
4251
const wasi = new WASI({
43-
args: [],
52+
args: [basename(filePath)].concat(args),
4453
env,
4554
features: features,
4655
});

test/wasi-test-suite/libstd.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ describe("wasi-test-suite-libstd", () => {
1212
"fs_metadata-file.wasm",
1313
"fs_rename-directory.wasm",
1414
"fs_rename-file.wasm",
15-
"env_args-many.wasm",
16-
"env_args-none.wasm",
17-
"env_args-some.wasm",
18-
"env_vars-many.wasm",
1915
]
2016

2117
for (const entry of entries) {

0 commit comments

Comments
 (0)