Skip to content

Commit

Permalink
Add ES5 and ES6 Conformance calculation to boa_tester
Browse files Browse the repository at this point in the history
This is calculated based the tests es5id or es6id
  • Loading branch information
ZackMitkin committed Mar 19, 2023
1 parent 7e6d3c9 commit 05d0659
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
40 changes: 38 additions & 2 deletions boa_tester/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,36 @@ impl TestSuite {
println!();
}

// Count passed tests
// Count passed tests and es specs
let mut passed = 0;
let mut ignored = 0;
let mut panic = 0;
let mut es5_passed = 0;
let mut es6_passed = 0;
let mut es5_total = 0;
let mut es6_total = 0;

for test in &tests {
match test.result {
TestOutcomeResult::Passed => passed += 1,
TestOutcomeResult::Passed => {
passed += 1;
if test.es5 {
es5_passed += 1;
}
if test.es6 {
es6_passed += 1;
}
}
TestOutcomeResult::Ignored => ignored += 1,
TestOutcomeResult::Panic => panic += 1,
TestOutcomeResult::Failed => {}
}
if test.es5 {
es5_total += 1;
}
if test.es6 {
es6_total += 1;
}
}

// Count total tests
Expand All @@ -77,6 +96,10 @@ impl TestSuite {
passed += suite.passed;
ignored += suite.ignored;
panic += suite.panic;
es5_total += suite.es5_total;
es6_total += suite.es6_total;
es5_passed += suite.es5_passed;
es6_passed += suite.es6_passed;
features.append(&mut suite.features.clone());
}

Expand Down Expand Up @@ -105,6 +128,10 @@ impl TestSuite {
ignored,
panic,
suites,
es5_total,
es6_total,
es5_passed,
es6_passed,
tests,
features,
}
Expand Down Expand Up @@ -141,6 +168,9 @@ impl Test {
}
return TestResult {
name: self.name.clone(),
es5: self.es5id.is_some(),
es6: self.es5id.is_some(),
spec_version: self.spec_version,
strict,
result: TestOutcomeResult::Failed,
result_text: Box::from("Could not read test file.")
Expand All @@ -159,6 +189,9 @@ impl Test {
}
return TestResult {
name: self.name.clone(),
es5: self.es5id.is_some(),
es6: self.es6id.is_some(),
spec_version: self.spec_version,
strict,
result: TestOutcomeResult::Ignored,
result_text: Box::default(),
Expand Down Expand Up @@ -357,6 +390,9 @@ impl Test {

TestResult {
name: self.name.clone(),
es5: self.es5id.is_some(),
es6: self.es6id.is_some(),
spec_version: self.spec_version,
strict,
result,
result_text: result_text.into_boxed_str(),
Expand Down
36 changes: 36 additions & 0 deletions boa_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ fn run_test_suite(
"Conformance: {:.2}%",
(results.passed as f64 / results.total as f64) * 100.0
);
println!(
"ES5 Conformance: {:.2}%",
(results.es5_passed as f64 / results.es5_total as f64) * 100.0
);
println!(
"ES6 Conformance: {:.2}%",
(results.es6_passed as f64 / results.es6_total as f64) * 100.0
);

write_json(results, output, verbose)
.wrap_err("could not write the results to the output JSON file")?;
Expand Down Expand Up @@ -331,6 +339,14 @@ struct SuiteResult {
ignored: usize,
#[serde(rename = "p")]
panic: usize,
#[serde(rename = "5t")]
es5_total: usize,
#[serde(rename = "6t")]
es6_total: usize,
#[serde(rename = "5p")]
es5_passed: usize,
#[serde(rename = "6p")]
es6_passed: usize,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
#[serde(rename = "s")]
suites: Vec<SuiteResult>,
Expand All @@ -348,6 +364,12 @@ struct SuiteResult {
struct TestResult {
#[serde(rename = "n")]
name: Box<str>,
#[serde(rename = "v", default)]
spec_version: Option<i8>,
#[serde(default)]
es5: bool,
#[serde(default)]
es6: bool,
#[serde(rename = "s", default)]
strict: bool,
#[serde(skip)]
Expand Down Expand Up @@ -375,6 +397,9 @@ struct Test {
name: Box<str>,
description: Box<str>,
esid: Option<Box<str>>,
spec_version: Option<i8>,
es5id: Option<Box<str>>,
es6id: Option<Box<str>>,
flags: TestFlags,
information: Box<str>,
features: Box<[Box<str>]>,
Expand All @@ -392,10 +417,21 @@ impl Test {
N: Into<Box<str>>,
C: Into<Box<Path>>,
{
let spec_version = if metadata.es5id.is_some() {
Some(5)
} else if metadata.es6id.is_some() {
Some(6)
} else {
None
};

Self {
name: name.into(),
description: metadata.description,
esid: metadata.esid,
spec_version,
es5id: metadata.es5id,
es6id: metadata.es6id,
flags: metadata.flags.into(),
information: metadata.info,
features: metadata.features,
Expand Down

0 comments on commit 05d0659

Please sign in to comment.