From 66c2bf4304d7878e1afaef3e881fd4d4e1760a96 Mon Sep 17 00:00:00 2001 From: Haled Odat <8566042+HalidOdat@users.noreply.github.com> Date: Sun, 15 Oct 2023 14:00:24 +0200 Subject: [PATCH] Prevent `test262` repository update if not needed (#3386) This also removes documentation section about `test262` submodule. --- CONTRIBUTING.md | 6 ------ boa_tester/src/main.rs | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5892b3078..fcf5dc45d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,12 +75,6 @@ with this command: cargo run --release --bin boa_tester -- run -v 2> error.log ``` -Note that this requires the `test262` submodule to be checked out, so you will need to run the following first: - -```shell -git submodule init && git submodule update -``` - This will run the test suite in verbose mode (you can remove the `-v` part to run it in non-verbose mode), and output nice colorings in the terminal. It will also output any panic information into the `error.log` file. diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index 2ca77a94b9..abbeb40672 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -294,7 +294,10 @@ fn main() -> Result<()> { } /// Returns the commit hash and commit message of the provided branch name. -fn get_last_branch_commit(branch: &str) -> Result<(String, String)> { +fn get_last_branch_commit(branch: &str, verbose: u8) -> Result<(String, String)> { + if verbose > 1 { + println!("Getting last commit on '{branch}' branch"); + } let result = Command::new("git") .arg("log") .args(["-n", "1"]) @@ -347,6 +350,15 @@ fn clone_test262(commit: Option<&str>, verbose: u8) -> Result<()> { let update = commit.is_none(); if Path::new(DEFAULT_TEST262_DIRECTORY).is_dir() { + let (current_commit_hash, current_commit_message) = + get_last_branch_commit("HEAD", verbose)?; + + if let Some(commit) = commit { + if current_commit_hash == commit { + return Ok(()); + } + } + if verbose != 0 { println!("Fetching latest test262 commits..."); } @@ -362,20 +374,17 @@ fn clone_test262(commit: Option<&str>, verbose: u8) -> Result<()> { ); } - let (current_commit_hash, current_commit_message) = get_last_branch_commit("HEAD")?; - if let Some(commit) = commit { - if current_commit_hash != commit { - println!("Test262 switching to commit {commit}..."); - reset_test262_commit(commit, verbose)?; - } + println!("Test262 switching to commit {commit}..."); + reset_test262_commit(commit, verbose)?; return Ok(()); } if verbose != 0 { println!("Checking latest Test262 with current HEAD..."); } - let (latest_commit_hash, latest_commit_message) = get_last_branch_commit("origin/main")?; + let (latest_commit_hash, latest_commit_message) = + get_last_branch_commit("origin/main", verbose)?; if current_commit_hash != latest_commit_hash { if update {