Skip to content

Commit

Permalink
remove testsuite-generated from source control (#227)
Browse files Browse the repository at this point in the history
Builds wast2json using the upstream WebAssembly source and some
build.zig and uses that to generate the testsuite json files on demand.

Tested on macOS/Windows and linux.
  • Loading branch information
marler8997 authored Jun 15, 2024
1 parent ba53488 commit bcb64e0
Show file tree
Hide file tree
Showing 5,748 changed files with 90 additions and 55,422 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 0 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ jobs:
version: 0.12.0
- name: Run testsuite
run: zig build testsuite
parsecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.12.0
- name: Build parsecheck
working-directory: ./test/parsecheck
run: zig build --prefix ./
- name: Run parse check
run: test/parsecheck/bin/parsecheck test/testsuite-generated
build_interface:
strategy:
matrix:
Expand Down
86 changes: 84 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub fn build(b: *Build) !void {
const unittest_step = b.step("unittest", "Run the library unittests");
unittest_step.dependOn(&run_main_tests.step);

const wast2json = addWast2Json(b);

const testrunner = b.addExecutable(.{
.name = "testrunner",
.root_source_file = b.path("test/testrunner/src/testrunner.zig"),
Expand All @@ -37,9 +39,14 @@ pub fn build(b: *Build) !void {

const testsuite_step = b.step("testsuite", "Run all the testsuite tests");
for (test_names) |test_name| {
const run_wast2json = b.addRunArtifact(wast2json);
run_wast2json.addFileArg(b.path(b.fmt("test/testsuite/{s}.wast", .{test_name})));
run_wast2json.addArg("-o");
const json_file = run_wast2json.addOutputFileArg(b.fmt("{s}.json", .{test_name}));

const run_test = b.addRunArtifact(testrunner);
run_test.addFileArg(b.path(b.fmt("test/testsuite-generated/{s}.json", .{test_name})));
run_test.cwd = b.path("test/testsuite-generated");
run_test.addFileArg(json_file);
run_test.cwd = json_file.dirname();
const step = b.step(b.fmt("test-{s}", .{test_name}), b.fmt("Run the '{s}' test", .{test_name}));
step.dependOn(&run_test.step);
testsuite_step.dependOn(&run_test.step);
Expand All @@ -50,6 +57,48 @@ pub fn build(b: *Build) !void {
test_step.dependOn(testsuite_step);
}

fn addWast2Json(b: *Build) *Build.Step.Compile {
const wabt_dep = b.dependency("wabt", .{});

const wabt_config_h = b.addConfigHeader(.{
.style = .{ .cmake = wabt_dep.path("src/config.h.in") },
.include_path = "wabt/config.h",
}, .{
.WABT_VERSION_STRING = "1.0.34",
.HAVE_SNPRINTF = 1,
.HAVE_SSIZE_T = 1,
.HAVE_STRCASECMP = 1,
.COMPILER_IS_CLANG = 1,
.SIZEOF_SIZE_T = @sizeOf(usize),
});

const wabt_lib = b.addStaticLibrary(.{
.name = "wabt",
.target = b.host,
.optimize = .Debug,
});
wabt_lib.addConfigHeader(wabt_config_h);
wabt_lib.addIncludePath(wabt_dep.path("include"));
wabt_lib.addCSourceFiles(.{
.root = wabt_dep.path("."),
.files = &wabt_files,
});
wabt_lib.linkLibCpp();

const wast2json = b.addExecutable(.{
.name = "wast2json",
.target = b.host,
});
wast2json.addConfigHeader(wabt_config_h);
wast2json.addIncludePath(wabt_dep.path("include"));
wast2json.addCSourceFile(.{
.file = wabt_dep.path("src/tools/wast2json.cc"),
});
wast2json.linkLibCpp();
wast2json.linkLibrary(wabt_lib);
return wast2json;
}

const test_names = [_][]const u8 {
"address",
"align",
Expand Down Expand Up @@ -141,3 +190,36 @@ const test_names = [_][]const u8 {
"utf8-import-module",
"utf8-invalid-encoding",
};

const wabt_files = [_][]const u8 {
"src/binary-reader-ir.cc",
"src/binary-reader-logging.cc",
"src/binary-reader.cc",
"src/binary-writer-spec.cc",
"src/binary-writer.cc",
"src/binary.cc",
"src/binding-hash.cc",
"src/color.cc",
"src/common.cc",
"src/error-formatter.cc",
"src/expr-visitor.cc",
"src/feature.cc",
"src/filenames.cc",
"src/ir.cc",
"src/leb128.cc",
"src/lexer-source-line-finder.cc",
"src/lexer-source.cc",
"src/literal.cc",
"src/opcode-code-table.c",
"src/opcode.cc",
"src/option-parser.cc",
"src/resolve-names.cc",
"src/shared-validator.cc",
"src/stream.cc",
"src/token.cc",
"src/type-checker.cc",
"src/utf8.cc",
"src/validator.cc",
"src/wast-lexer.cc",
"src/wast-parser.cc",
};
7 changes: 6 additions & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
.name = "zware",
.version = "0.0.1",

.dependencies = .{},
.dependencies = .{
.wabt = .{
.url = "https://github.com/WebAssembly/wabt/archive/39f85a791cbbad91a253a851841a29777efdc2cd.tar.gz",
.hash = "1220097b5cfb369f95493a753b0b12525f065e2cf607d62e314d54c54aa1071a1eed",
},
},
}
158 changes: 0 additions & 158 deletions test/generate.sh

This file was deleted.

26 changes: 0 additions & 26 deletions test/parsecheck/build.zig

This file was deleted.

61 changes: 0 additions & 61 deletions test/parsecheck/src/parsecheck.zig

This file was deleted.

Binary file removed test/testsuite-generated/27_1.if.50.wasm
Binary file not shown.
Binary file removed test/testsuite-generated/2966_5.left-to-right.0.wasm
Binary file not shown.
Binary file removed test/testsuite-generated/address.0.wasm
Binary file not shown.
1 change: 0 additions & 1 deletion test/testsuite-generated/address.1.wat

This file was deleted.

Binary file removed test/testsuite-generated/address.2.wasm
Binary file not shown.
Binary file removed test/testsuite-generated/address.3.wasm
Binary file not shown.
Binary file removed test/testsuite-generated/address.4.wasm
Binary file not shown.
Loading

0 comments on commit bcb64e0

Please sign in to comment.