diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index 6d4e367e11..96cf6e59ce 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -43,6 +43,13 @@ impl TestSuite { .collect() }; + let mut features = Vec::new(); + for test_iter in self.tests.iter() { + for feature_iter in test_iter.features.iter() { + features.push(feature_iter.to_string()); + } + } + if verbose != 0 { println!(); } @@ -67,6 +74,7 @@ impl TestSuite { passed += suite.passed; ignored += suite.ignored; panic += suite.panic; + features.append(&mut suite.features.clone()); } if verbose != 0 { @@ -95,6 +103,7 @@ impl TestSuite { panic, suites, tests, + features, } } } diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index 1546b2f758..d8895830ef 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -357,6 +357,9 @@ struct SuiteResult { #[serde(rename = "t")] #[serde(skip_serializing_if = "Vec::is_empty", default)] tests: Vec, + #[serde(rename = "f")] + #[serde(skip_serializing_if = "Vec::is_empty", default)] + features: Vec, } /// Outcome of a test. diff --git a/boa_tester/src/results.rs b/boa_tester/src/results.rs index 6f837c352a..3f369c4f50 100644 --- a/boa_tester/src/results.rs +++ b/boa_tester/src/results.rs @@ -50,12 +50,45 @@ impl From for ReducedResultInfo { } } +#[derive(Debug, Clone, Deserialize, Serialize)] +struct FeaturesInfo { + #[serde(rename = "c")] + commit: Box, + #[serde(rename = "u")] + test262_commit: Box, + #[serde(rename = "n")] + suite_name: Box, + #[serde(rename = "f")] + features: Vec, +} + +fn remove_duplicates(features_vec: &[String]) -> Vec { + let mut result = features_vec.to_vec(); + result.sort(); + result.dedup(); + result +} + +impl From for FeaturesInfo { + fn from(info: ResultInfo) -> Self { + Self { + commit: info.commit, + test262_commit: info.test262_commit, + suite_name: info.results.name, + features: remove_duplicates(&info.results.features), + } + } +} + /// File name of the "latest results" JSON file. const LATEST_FILE_NAME: &str = "latest.json"; /// File name of the "all results" JSON file. const RESULTS_FILE_NAME: &str = "results.json"; +/// File name of the "features" JSON file. +const FEATURES_FILE_NAME: &str = "features.json"; + /// Writes the results of running the test suite to the given JSON output file. /// /// It will append the results to the ones already present, in an array. @@ -108,7 +141,7 @@ pub(crate) fn write_json( Vec::new() }; - all_results.push(new_results.into()); + all_results.push(new_results.clone().into()); let output = BufWriter::new(fs::File::create(&all_path)?); serde_json::to_writer(output, &all_results)?; @@ -116,6 +149,25 @@ pub(crate) fn write_json( if verbose != 0 { println!("Results written correctly"); } + + // Write the full list of features, existing features go first. + + let features_path = path.join(FEATURES_FILE_NAME); + + let mut all_features: Vec = if features_path.exists() { + serde_json::from_reader(BufReader::new(fs::File::open(&features_path)?))? + } else { + Vec::new() + }; + + all_features.push(new_results.into()); + + let features_output = BufWriter::new(fs::File::create(&features_path)?); + serde_json::to_writer(features_output, &all_features)?; + + if verbose != 0 { + println!("Features written correctly"); + } } Ok(())