diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index 0af19af6f8c..594c538a317 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -789,7 +789,7 @@ impl AddAssign for VersionedStats { struct SuiteResult { #[serde(rename = "a")] stats: Statistics, - #[serde(rename = "av", default)] + #[serde(rename = "v", default)] versioned_stats: VersionedStats, #[serde(skip_serializing_if = "FxHashMap::is_empty", default)] #[serde(rename = "s")] diff --git a/boa_tester/src/results.rs b/boa_tester/src/results.rs index 702a71a0e70..9374740198b 100644 --- a/boa_tester/src/results.rs +++ b/boa_tester/src/results.rs @@ -2,6 +2,7 @@ use crate::{Statistics, TestOutcomeResult, VersionedStats}; use super::SuiteResult; use color_eyre::{eyre::WrapErr, Result}; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use std::{ env, fs, @@ -16,8 +17,12 @@ struct ResultInfo { commit: Box, #[serde(rename = "u")] test262_commit: Box, + #[serde(rename = "a")] + stats: Statistics, + #[serde(rename = "v")] + versioned_results: VersionedStats, #[serde(rename = "r")] - results: SuiteResult, + results: FxHashMap, SuiteResult>, } /// Structure to store full result information. @@ -29,8 +34,6 @@ struct ReducedResultInfo { test262_commit: Box, #[serde(rename = "a")] stats: Statistics, - #[serde(rename = "av", default)] - versioned_stats: VersionedStats, } impl From for ReducedResultInfo { @@ -39,8 +42,7 @@ impl From for ReducedResultInfo { Self { commit: info.commit, test262_commit: info.test262_commit, - stats: info.results.stats, - versioned_stats: info.results.versioned_stats, + stats: info.stats, } } } @@ -68,13 +70,13 @@ pub(crate) fn write_json( let output_dir = if branch.is_empty() { output_dir.to_path_buf() } else { - let folder = output_dir.join(branch); + let folder = output_dir.join(&branch); fs::create_dir_all(&folder)?; folder }; // We make sure we are using the latest commit information in GitHub pages: - update_gh_pages_repo(output_dir.as_path(), verbose); + update_gh_pages_repo(output_dir.as_path(), &branch, verbose); if verbose != 0 { println!("Writing the results to {}...", output_dir.display()); @@ -86,27 +88,32 @@ pub(crate) fn write_json( let new_results = ResultInfo { commit: env::var("GITHUB_SHA").unwrap_or_default().into_boxed_str(), - test262_commit: get_test262_commit(test262_path)?, - results, + test262_commit: get_test262_commit(test262_path) + .context("could not get the test262 commit")?, + stats: results.stats, + versioned_results: results.versioned_stats, + results: results.suites, }; let latest = BufWriter::new(fs::File::create(latest)?); serde_json::to_writer(latest, &new_results)?; - // Write the full list of results, retrieving the existing ones first. + // Write the full result history for "main" + if branch == "main" { + let all_path = output_dir.join(RESULTS_FILE_NAME); - let all_path = output_dir.join(RESULTS_FILE_NAME); - - let mut all_results: Vec = if all_path.exists() { - serde_json::from_reader(BufReader::new(fs::File::open(&all_path)?))? - } else { - Vec::new() - }; + // We only keep history for the main branch + let mut all_results: Vec = if all_path.is_file() { + serde_json::from_reader(BufReader::new(fs::File::open(&all_path)?))? + } else { + Vec::new() + }; - all_results.push(new_results.into()); + all_results.push(new_results.into()); - let output = BufWriter::new(fs::File::create(&all_path)?); - serde_json::to_writer(output, &all_results)?; + let output = BufWriter::new(fs::File::create(&all_path)?); + serde_json::to_writer(output, &all_results)?; + } if verbose != 0 { println!("Results written correctly"); @@ -125,17 +132,20 @@ fn get_test262_commit(test262_path: &Path) -> Result> { } /// Updates the GitHub pages repository by pulling latest changes before writing the new things. -fn update_gh_pages_repo(path: &Path, verbose: u8) { - if env::var("GITHUB_REF").is_ok() { - use std::process::Command; +fn update_gh_pages_repo(path: &Path, branch: &str, verbose: u8) { + use std::process::Command; - // We run the command to pull the gh-pages branch: git -C ../gh-pages/ pull origin - Command::new("git") - .args(["-C", "../gh-pages", "pull", "--ff-only"]) - .output() - .expect("could not update GitHub Pages"); + // We run the command to pull the gh-pages branch: git -C ../gh-pages/ pull --ff-only + if verbose != 0 { + println!("Cloning the Github Pages branch in ../gh-pages/..."); + } + Command::new("git") + .args(["-C", "../gh-pages", "pull", "--ff-only"]) + .output() + .expect("could not update GitHub Pages"); - // Copy the full results file + if branch == "main" { + // Copy the full results file if in the main branch let from = Path::new("../gh-pages/test262/refs/heads/main/").join(RESULTS_FILE_NAME); let to = path.join(RESULTS_FILE_NAME); @@ -147,8 +157,6 @@ fn update_gh_pages_repo(path: &Path, verbose: u8) { ); } - // TO-DO: only copy the last result, not the whole file. - fs::copy(from, to).expect("could not copy the main results file"); } } @@ -166,24 +174,24 @@ pub(crate) fn compare_results(base: &Path, new: &Path, markdown: bool) -> Result )) .wrap_err("could not read the new results")?; - let base_total = base_results.results.stats.total as isize; - let new_total = new_results.results.stats.total as isize; + let base_total = base_results.stats.total as isize; + let new_total = new_results.stats.total as isize; let total_diff = new_total - base_total; - let base_passed = base_results.results.stats.passed as isize; - let new_passed = new_results.results.stats.passed as isize; + let base_passed = base_results.stats.passed as isize; + let new_passed = new_results.stats.passed as isize; let passed_diff = new_passed - base_passed; - let base_ignored = base_results.results.stats.ignored as isize; - let new_ignored = new_results.results.stats.ignored as isize; + let base_ignored = base_results.stats.ignored as isize; + let new_ignored = new_results.stats.ignored as isize; let ignored_diff = new_ignored - base_ignored; let base_failed = base_total - base_passed - base_ignored; let new_failed = new_total - new_passed - new_ignored; let failed_diff = new_failed - base_failed; - let base_panics = base_results.results.stats.panic as isize; - let new_panics = new_results.results.stats.panic as isize; + let base_panics = base_results.stats.panic as isize; + let new_panics = new_results.stats.panic as isize; let panic_diff = new_panics - base_panics; let base_conformance = (base_passed as f64 / base_total as f64) * 100_f64; @@ -406,8 +414,8 @@ impl ResultDiff { /// Compares a base and a new result and returns the list of differences. fn compute_result_diff( base: &Path, - base_result: &SuiteResult, - new_result: &SuiteResult, + base_result: &FxHashMap, SuiteResult>, + new_result: &FxHashMap, SuiteResult>, ) -> ResultDiff { let mut final_diff = ResultDiff::default();