Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@

public class Specification {
private final List<String> args;
private final List<String> dirs;
private final Optional<String> root;
private final Map<String, String> env;
private final int exitCode;
private final Optional<String> stdout;

@JsonCreator
public Specification(
@JsonProperty("args") List<String> args,
@JsonProperty("dirs") List<String> dirs,
@JsonProperty("root") String root,
@JsonProperty("env") Map<String, String> env,
@JsonProperty("exit_code") int exitCode,
@JsonProperty("stdout") String stdout) {
this.args = requireNonNullElse(args, emptyList());
this.dirs = requireNonNullElse(dirs, emptyList());
this.root = Optional.ofNullable(root);
this.env = requireNonNullElse(env, emptyMap());
this.exitCode = exitCode;
this.stdout = Optional.ofNullable(stdout);
Expand All @@ -35,8 +35,8 @@ public List<String> args() {
return args;
}

public List<String> dirs() {
return dirs;
public Optional<String> root() {
return root;
}

public Map<String, String> env() {
Expand All @@ -52,6 +52,6 @@ public Optional<String> stdout() {
}

public static Specification createDefault() {
return new Specification(emptyList(), emptyList(), emptyMap(), 0, null);
return new Specification(emptyList(), null, emptyMap(), 0, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public void execute() throws MojoExecutionException {
AssignExpr.Operator.ASSIGN))
.addStatement(
new AssignExpr(
new NameExpr("List<String> dirs"),
new NameExpr(listOf(specification.dirs())),
new NameExpr("Optional<String> root"),
new NameExpr(optionalOf(specification.root())),
AssignExpr.Operator.ASSIGN))
.addStatement(
new AssignExpr(
Expand All @@ -208,7 +208,7 @@ public void execute() throws MojoExecutionException {
.addStatement(
new NameExpr(
"WasiTestRunner.execute("
+ "test, args, dirs, env, exitCode, stdout)"));
+ "test, args, root, env, exitCode, stdout)"));
}

dest.add(
Expand Down
10 changes: 5 additions & 5 deletions wasi-tests/src/test/java/run/endive/wasi/WasiTestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private WasiTestRunner() {}
public static void execute(
File test,
List<String> args,
List<String> dirs,
Optional<String> root,
Map<String, String> env,
int exitCode,
Optional<String> stdout) {
Expand Down Expand Up @@ -55,11 +55,11 @@ public static void execute(
options.withEnvironment("NO_DANGLING_FILESYSTEM", "true");
}

for (String dir : dirs) {
Path source = test.getParentFile().toPath().resolve(dir);
Path target = fs.getPath(dir);
if (root.isPresent()) {
Path source = test.getParentFile().toPath().resolve(root.get());
Path target = fs.getPath("/");
copyDirectory(source, target);
options.withDirectory(target.toString(), target);
options.withDirectory("/", target);
}

int actualExitCode;
Expand Down
Loading