Browse Source

Retrieve feature-based results for Test262 runs (#1980)

This Pull Request fixes/closes #1645.

It changes the following:

- Add `features` field to `SuiteResult` structure
- Fetch features from `TestSuite` and propagate them via `SuiteResult`
- Add `FeaturesInfo` structure and serialize it to `features.json`
pull/1985/head
NorbertGarfield 3 years ago
parent
commit
5a2703b2d3
  1. 9
      boa_tester/src/exec/mod.rs
  2. 3
      boa_tester/src/main.rs
  3. 54
      boa_tester/src/results.rs

9
boa_tester/src/exec/mod.rs

@ -43,6 +43,13 @@ impl TestSuite {
.collect() .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 { if verbose != 0 {
println!(); println!();
} }
@ -67,6 +74,7 @@ impl TestSuite {
passed += suite.passed; passed += suite.passed;
ignored += suite.ignored; ignored += suite.ignored;
panic += suite.panic; panic += suite.panic;
features.append(&mut suite.features.clone());
} }
if verbose != 0 { if verbose != 0 {
@ -95,6 +103,7 @@ impl TestSuite {
panic, panic,
suites, suites,
tests, tests,
features,
} }
} }
} }

3
boa_tester/src/main.rs

@ -357,6 +357,9 @@ struct SuiteResult {
#[serde(rename = "t")] #[serde(rename = "t")]
#[serde(skip_serializing_if = "Vec::is_empty", default)] #[serde(skip_serializing_if = "Vec::is_empty", default)]
tests: Vec<TestResult>, tests: Vec<TestResult>,
#[serde(rename = "f")]
#[serde(skip_serializing_if = "Vec::is_empty", default)]
features: Vec<String>,
} }
/// Outcome of a test. /// Outcome of a test.

54
boa_tester/src/results.rs

@ -50,12 +50,45 @@ impl From<ResultInfo> for ReducedResultInfo {
} }
} }
#[derive(Debug, Clone, Deserialize, Serialize)]
struct FeaturesInfo {
#[serde(rename = "c")]
commit: Box<str>,
#[serde(rename = "u")]
test262_commit: Box<str>,
#[serde(rename = "n")]
suite_name: Box<str>,
#[serde(rename = "f")]
features: Vec<String>,
}
fn remove_duplicates(features_vec: &[String]) -> Vec<String> {
let mut result = features_vec.to_vec();
result.sort();
result.dedup();
result
}
impl From<ResultInfo> 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. /// File name of the "latest results" JSON file.
const LATEST_FILE_NAME: &str = "latest.json"; const LATEST_FILE_NAME: &str = "latest.json";
/// File name of the "all results" JSON file. /// File name of the "all results" JSON file.
const RESULTS_FILE_NAME: &str = "results.json"; 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. /// 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. /// It will append the results to the ones already present, in an array.
@ -108,7 +141,7 @@ pub(crate) fn write_json(
Vec::new() Vec::new()
}; };
all_results.push(new_results.into()); all_results.push(new_results.clone().into());
let output = BufWriter::new(fs::File::create(&all_path)?); let output = BufWriter::new(fs::File::create(&all_path)?);
serde_json::to_writer(output, &all_results)?; serde_json::to_writer(output, &all_results)?;
@ -116,6 +149,25 @@ pub(crate) fn write_json(
if verbose != 0 { if verbose != 0 {
println!("Results written correctly"); 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<FeaturesInfo> = 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(()) Ok(())

Loading…
Cancel
Save