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

[Merged by Bors] - Retrieve feature-based results for Test262 runs #1980

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions boa_tester/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
}
Expand All @@ -67,6 +74,7 @@ impl TestSuite {
passed += suite.passed;
ignored += suite.ignored;
panic += suite.panic;
features.append(&mut suite.features.clone())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is giving a clippy warning, should be fixed with this:

Suggested change
features.append(&mut suite.features.clone())
features.append(&mut suite.features.clone());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

if verbose != 0 {
Expand Down Expand Up @@ -95,6 +103,7 @@ impl TestSuite {
panic,
suites,
tests,
features,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions boa_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ struct SuiteResult {
#[serde(rename = "t")]
#[serde(skip_serializing_if = "Vec::is_empty", default)]
tests: Vec<TestResult>,
#[serde(rename = "f")]
#[serde(skip_serializing_if = "Vec::is_empty", default)]
features: Vec<String>,
}

/// Outcome of a test.
Expand Down
54 changes: 53 additions & 1 deletion boa_tester/src/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: &Vec<String>) -> Vec<String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should solve the clippy error, but might need some changes in the code to convert the slice to a vector.

Suggested change
fn remove_duplicates(features_vec: &Vec<String>) -> Vec<String> {
fn remove_duplicates(features_vec: &[String]) -> Vec<String> {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let mut result = features_vec.clone();
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.
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.
Expand Down Expand Up @@ -108,14 +141,33 @@ 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)?;

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<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(())
Expand Down