add ONCE call to copy zig glue files when running tests

This commit is contained in:
Luke Boswell 2024-07-28 15:41:57 +10:00
parent 6278c4d7bb
commit 41192b7103
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 15 additions and 0 deletions

View file

@ -14,6 +14,7 @@ roc_load = { path = "../compiler/load" }
roc_module = { path = "../compiler/module" }
roc_reporting = { path = "../reporting" }
roc_command_utils = { path = "../utils/command" }
copy_zig_glue = { path = "../copy_zig_glue" }
bumpalo.workspace = true
criterion.workspace = true

View file

@ -14,8 +14,11 @@ use std::io::Write;
use std::path::PathBuf;
use std::process::{Command, ExitStatus, Stdio};
use std::sync::Mutex;
use std::sync::Once;
use tempfile::NamedTempFile;
static ZIG_PLATFORM_COPY_GLUE_ONCE: Once = Once::new();
#[derive(Debug)]
pub struct Out {
pub cmd_str: OsString, // command with all its arguments, for easy debugging
@ -122,6 +125,8 @@ where
roc_cmd.arg(arg);
}
initialize_zig_test_platforms();
for (k, v) in extra_env {
roc_cmd.env(k, v);
}
@ -473,3 +478,12 @@ pub fn known_bad_file(file_name: &str) -> PathBuf {
path
}
/// Copies the glue source files for zig platforms from the roc builtins
/// this is only temporary, see comments in crates/copy_zig_glue/src/main.rs
fn initialize_zig_test_platforms() {
ZIG_PLATFORM_COPY_GLUE_ONCE.call_once(|| {
// initialization code here
copy_zig_glue::copy_zig_glue();
});
}