Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running a specific test/suite in boa_tester #886

Merged
merged 1 commit into from
Oct 18, 2020
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
54 changes: 38 additions & 16 deletions boa_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>,
Expand All @@ -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()
Expand All @@ -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.
Expand Down
11 changes: 2 additions & 9 deletions boa_tester/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(|| {
Expand Down