Skip to content

Commit

Permalink
Merge pull request #13 from optimism-java/spec-test
Browse files Browse the repository at this point in the history
feat: run spec test in condition
  • Loading branch information
GrapeBaBa authored Oct 31, 2024
2 parents 6f911a7 + fa3be4d commit 9c43041
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,19 @@ git submodule update --init --recursive
cd bls
make -f Makefile.onelib ETH_CFLAGS=-DBLS_ETH LIB_DIR=lib
zig build
```
```

## Test

first you should build bls as described above

when you run `zig build test`, the spec tests are not run by default.

if you want to run spec tests, you need to download the test vectors and add `-Dspec=true` to the zig build command.

```bash
# download test vectors
make deps_test
# add -Dspec=true to run spec tests
zig build test -Dspec=true
```
13 changes: 13 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,17 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
test_step.dependOn(&run_exe_unit_tests.step);

const spec: ?bool = b.option(bool, "spec", "whether to run the spec tests");
if (spec) |s| {
if (s) {
const spec_tests = b.addTest(.{
.root_source_file = b.path("src/spec_test.zig"),
.target = target,
.optimize = optimize,
});
const run_spec_tests = b.addRunArtifact(spec_tests);
test_step.dependOn(&run_spec_tests.step);
}
}
}
1 change: 0 additions & 1 deletion src/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ pub const deposit_helper = @import("consensus/helpers/deposit.zig");

test {
@import("std").testing.refAllDeclsRecursive(@This());
_ = @import("./spec_tests/root.zig");
}
3 changes: 3 additions & 0 deletions src/spec_test.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test {
_ = @import("./spec_tests/root.zig");
}

0 comments on commit 9c43041

Please sign in to comment.