diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index f6c16efa19..7b8ca624e4 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -41,7 +41,7 @@ mod read; mod results; use self::{ - read::{read_global_suite, read_harness, MetaData, Negative, TestFlag}, + read::{read_harness, read_suite, read_test, MetaData, Negative, TestFlag}, results::write_json, }; use bitflags::bitflags; @@ -69,6 +69,10 @@ struct Cli { #[structopt(long, parse(from_os_str), default_value = "./test262")] test262_path: PathBuf, + /// Which specific test or test suite to run. + #[structopt(short, long, parse(from_os_str), default_value = "test")] + suite: PathBuf, + /// Optional output folder for the full results information. #[structopt(short, long, parse(from_os_str))] output: Option, @@ -85,6 +89,11 @@ impl Cli { self.test262_path.as_path() } + /// Which specific test or test suite to run. + fn suite(&self) -> &Path { + self.suite.as_path() + } + /// Optional output folder for the full results information. fn output(&self) -> Option<&Path> { self.output.as_deref() @@ -109,23 +118,36 @@ fn main() { } let harness = read_harness().expect("could not read initialization bindings"); - let global_suite = read_global_suite().expect("could not get the list of tests to run"); + if CLI.suite().to_string_lossy().ends_with(".js") { + let test = read_test(&CLI.test262_path().join(CLI.suite())) + .expect("could not get the test to run"); - if CLI.verbose() { - println!("Test suite loaded, starting tests..."); + if CLI.verbose() { + println!("Test loaded, starting..."); + } + test.run(&harness); + + println!(); + } else { + let suite = read_suite(&CLI.test262_path().join(CLI.suite())) + .expect("could not get the list of tests to run"); + + if CLI.verbose() { + println!("Test suite loaded, starting tests..."); + } + let results = suite.run(&harness); + + println!(); + println!("Results:"); + println!("Total tests: {}", results.total); + println!("Passed tests: {}", results.passed); + println!( + "Conformance: {:.2}%", + (results.passed as f64 / results.total as f64) * 100.0 + ); + + write_json(results).expect("could not write the results to the output JSON file"); } - let results = global_suite.run(&harness); - println!(); - - println!("Results:"); - println!("Total tests: {}", results.total); - println!("Passed tests: {}", results.passed); - println!( - "Conformance: {:.2}%", - (results.passed as f64 / results.total as f64) * 100.0 - ); - - write_json(results).expect("could not write the results to the output JSON file"); } /// All the harness include files. diff --git a/boa_tester/src/read.rs b/boa_tester/src/read.rs index 877be836a7..c914af03b1 100644 --- a/boa_tester/src/read.rs +++ b/boa_tester/src/read.rs @@ -82,15 +82,8 @@ pub(super) fn read_harness() -> io::Result { }) } -/// Reads the global suite from disk. -pub(super) fn read_global_suite() -> io::Result { - let path = CLI.test262_path().join("test"); - - Ok(read_suite(path.as_path())?) -} - /// Reads a test suite in the given path. -fn read_suite(path: &Path) -> io::Result { +pub(super) fn read_suite(path: &Path) -> io::Result { use std::ffi::OsStr; let name = path @@ -139,7 +132,7 @@ fn read_suite(path: &Path) -> io::Result { } /// Reads information about a given test case. -fn read_test(path: &Path) -> io::Result { +pub(super) fn read_test(path: &Path) -> io::Result { let name = path .file_stem() .ok_or_else(|| {