Browse Source

Support running a specific test/suite in boa_tester (#886)

pull/888/head
George Roman 4 years ago committed by GitHub
parent
commit
09d1889aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      boa_tester/src/main.rs
  2. 11
      boa_tester/src/read.rs

30
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<PathBuf>,
@ -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,14 +118,26 @@ 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...");
println!("Test loaded, starting...");
}
let results = global_suite.run(&harness);
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);
@ -126,6 +147,7 @@ fn main() {
);
write_json(results).expect("could not write the results to the output JSON file");
}
}
/// All the harness include files.

11
boa_tester/src/read.rs

@ -82,15 +82,8 @@ pub(super) fn read_harness() -> io::Result<Harness> {
})
}
/// Reads the global suite from disk.
pub(super) fn read_global_suite() -> io::Result<TestSuite> {
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<TestSuite> {
pub(super) fn read_suite(path: &Path) -> io::Result<TestSuite> {
use std::ffi::OsStr;
let name = path
@ -139,7 +132,7 @@ fn read_suite(path: &Path) -> io::Result<TestSuite> {
}
/// Reads information about a given test case.
fn read_test(path: &Path) -> io::Result<Test> {
pub(super) fn read_test(path: &Path) -> io::Result<Test> {
let name = path
.file_stem()
.ok_or_else(|| {

Loading…
Cancel
Save