about summary refs log tree commit diff
diff options
context:
space:
mode:
authorantoyo <antoyo@users.noreply.github.com>2023-12-21 16:11:03 -0500
committerGitHub <noreply@github.com>2023-12-21 16:11:03 -0500
commitb2e0cc5cec26881586a557ecd89487881597bbf8 (patch)
tree7bc1f690dc1b4abeb1a47a4f18237eded0197c80
parenta53495ab45a1d7773561431eb2fb753aee102d44 (diff)
parent6631dd9dd27b63bf89d3ace5dbce02ea240c5a44 (diff)
downloadrust-b2e0cc5cec26881586a557ecd89487881597bbf8.tar.gz
rust-b2e0cc5cec26881586a557ecd89487881597bbf8.zip
Merge pull request #399 from GuillaumeGomez/checkout
If the rustc commit cannot be retrieve, just checkout the repository
-rw-r--r--build_system/src/test.rs38
1 files changed, 24 insertions, 14 deletions
diff --git a/build_system/src/test.rs b/build_system/src/test.rs
index f66b16c3149..1a9bb4ea94e 100644
--- a/build_system/src/test.rs
+++ b/build_system/src/test.rs
@@ -503,7 +503,15 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
         Some(commit_hash) => commit_hash,
         None => return Err("Couldn't retrieve rustc commit hash".to_string()),
     };
-    run_command_with_output_and_env(&[&"git", &"checkout", &rustc_commit], rust_dir, Some(env))?;
+    if rustc_commit != "unknown" {
+        run_command_with_output_and_env(
+            &[&"git", &"checkout", &rustc_commit],
+            rust_dir,
+            Some(env),
+        )?;
+    } else {
+        run_command_with_output_and_env(&[&"git", &"checkout"], rust_dir, Some(env))?;
+    }
     let cargo = String::from_utf8(
         run_command_with_env(&[&"rustup", &"which", &"cargo"], rust_dir, Some(env))?.stdout,
     )
@@ -516,23 +524,25 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
             Ok(cargo)
         }
     })?;
-    let llvm_filecheck = String::from_utf8(
-        run_command_with_env(
-            &[
-                &"bash",
-                &"-c",
-                &"which FileCheck-10 || \
+    let llvm_filecheck = match run_command_with_env(
+        &[
+            &"bash",
+            &"-c",
+            &"which FileCheck-10 || \
           which FileCheck-11 || \
           which FileCheck-12 || \
           which FileCheck-13 || \
           which FileCheck-14",
-            ],
-            rust_dir,
-            Some(env),
-        )?
-        .stdout,
-    )
-    .map_err(|error| format!("Failed to retrieve LLVM FileCheck: {:?}", error))?;
+        ],
+        rust_dir,
+        Some(env),
+    ) {
+        Ok(cmd) => String::from_utf8_lossy(&cmd.stdout).to_string(),
+        Err(_) => {
+            eprintln!("Failed to retrieve LLVM FileCheck, ignoring...");
+            String::new()
+        }
+    };
     std::fs::write(
         "rust/config.toml",
         &format!(