Skip to content

Commit dcfab66

Browse files
committed
Allow tester to compare directories
The compare command now accepts directories as arguments and will automatically use the latest.json file from those directories. This maintains backward compatibility with explicit file paths.
1 parent 085fbd3 commit dcfab66

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,33 @@ be more readable if you disable parallelism with the `-d` flag. All together it
9191
cargo run --release --bin boa_tester -- run -vv -d -s test/language/types/number 2> error.log
9292
```
9393

94+
To save test results for later comparison, use the `-o` flag to specify an output directory:
95+
96+
```shell
97+
cargo run --release --bin boa_tester -- run -o ./test-results
98+
```
99+
100+
### Comparing Test Results
101+
102+
You can compare two test suite runs to see what changed:
103+
104+
```shell
105+
cargo run --release --bin boa_tester -- compare <base-results> <new-results>
106+
```
107+
108+
Both arguments can be either result files (e.g., `latest.json`) or directories containing test results.
109+
When directories are provided, the tester automatically uses the `latest.json` file from each directory.
110+
111+
For example:
112+
113+
```shell
114+
# Compare using directories
115+
cargo run --release --bin boa_tester -- compare ./test-results-main ./test-results-feature
116+
117+
# Compare using explicit files
118+
cargo run --release --bin boa_tester -- compare ./test-results-main/latest.json ./test-results-feature/latest.json
119+
```
120+
94121
## Documentation
95122

96123
To build the development documentation, run:

tests/tester/src/results.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,26 @@ fn get_test262_commit(test262_path: &Path) -> Result<Box<str>> {
170170
/// Compares the results of two test suite runs.
171171
#[allow(clippy::cast_possible_wrap)]
172172
pub(crate) fn compare_results(base: &Path, new: &Path, markdown: bool) -> Result<()> {
173+
// If the path is a directory, use latest.json from that directory
174+
let base_path = if base.is_dir() {
175+
base.join(LATEST_FILE_NAME)
176+
} else {
177+
base.to_path_buf()
178+
};
179+
180+
let new_path = if new.is_dir() {
181+
new.join(LATEST_FILE_NAME)
182+
} else {
183+
new.to_path_buf()
184+
};
185+
173186
let base_results: ResultInfo = serde_json::from_reader(BufReader::new(
174-
fs::File::open(base).wrap_err("could not open the base results file")?,
187+
fs::File::open(&base_path).wrap_err("could not open the base results file")?,
175188
))
176189
.wrap_err("could not read the base results")?;
177190

178191
let new_results: ResultInfo = serde_json::from_reader(BufReader::new(
179-
fs::File::open(new).wrap_err("could not open the new results file")?,
192+
fs::File::open(&new_path).wrap_err("could not open the new results file")?,
180193
))
181194
.wrap_err("could not read the new results")?;
182195

0 commit comments

Comments
 (0)