Skip to content

Commit

Permalink
fix: create test dir if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
xffxff committed Sep 24, 2023
1 parent f18b96f commit c85954e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions lox_tests/var.lox
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var a = 1;
3 changes: 3 additions & 0 deletions lox_tests/var/bytecode
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Chunk {
code: [],
}
12 changes: 12 additions & 0 deletions lox_tests/var/syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Diagnostic {
severity: Error,
span: @0..@3,
message: "extra tokens after statement",
labels: [
Label {
span: @0..@3,
message: "here",
},
],
children: [],
}
13 changes: 13 additions & 0 deletions lox_tests/var/token
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
TokenTree {
source text: "var a = 1;",
tokens: [
Alphabetic(var),
Whitespace(' '),
Alphabetic(a),
Whitespace(' '),
Op(=),
Whitespace(' '),
Number(1),
Semicolon,
],
}
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl TestCase {
// `foo/bar/{token,syntax,bytecode,execute}`
let parent = lox.parent().unwrap();
let lox_dir = parent.join(lox.file_stem().unwrap());
if !lox_dir.exists() {
fs::create_dir(&lox_dir).unwrap();
}

let token = lox_dir.join("token");
let syntax = lox_dir.join("syntax");
let bytecode = lox_dir.join("bytecode");
Expand Down

0 comments on commit c85954e

Please sign in to comment.