From f8304477f69ee80db1a7ed9f3c366ff3f49304e6 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Wed, 13 Nov 2024 09:32:28 +1100 Subject: [PATCH] use initialize_zig_test_platforms in all cli_tests --- crates/cli/tests/cli_tests.rs | 12 ++++++++++++ crates/copy_zig_glue/src/lib.rs | 8 ++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/cli/tests/cli_tests.rs b/crates/cli/tests/cli_tests.rs index a3b988e4dc..ef78869552 100644 --- a/crates/cli/tests/cli_tests.rs +++ b/crates/cli/tests/cli_tests.rs @@ -76,6 +76,8 @@ mod cli_tests { #[test] #[cfg_attr(windows, ignore)] fn platform_switching_zig() { + copy_zig_glue::initialize_zig_test_platforms(); + let cli_build = ExecCli::new( CMD_BUILD, file_from_root("examples/platform-switching", "rocLovesZig.roc"), @@ -96,6 +98,8 @@ mod cli_tests { #[test] fn platform_switching_wasm() { + copy_zig_glue::initialize_zig_test_platforms(); + // this is a web assembly example, but we don't test with JS at the moment // so let's just check it for now let cli_check = ExecCli::new( @@ -113,6 +117,8 @@ mod cli_tests { ignore = "Flaky failure: Roc command failed with status ExitStatus(ExitStatus(3221225477))" )] fn fibonacci() { + copy_zig_glue::initialize_zig_test_platforms(); + let cli_build = ExecCli::new( CMD_BUILD, file_from_root("crates/cli/tests/test-projects/algorithms", "fibonacci.roc"), @@ -134,6 +140,8 @@ mod cli_tests { #[test] #[cfg_attr(windows, ignore)] fn quicksort() { + copy_zig_glue::initialize_zig_test_platforms(); + let cli_build = ExecCli::new( CMD_BUILD, file_from_root("crates/cli/tests/test-projects/algorithms", "quicksort.roc"), @@ -983,6 +991,8 @@ mod cli_tests { /// Build the platform host once for all tests in this module fn build_platform_host() { BUILD_PLATFORM_HOST.call_once(|| { + copy_zig_glue::initialize_zig_test_platforms(); + let cli_build = ExecCli::new( CMD_BUILD, file_from_root("crates/cli/tests/benchmarks/platform", "app.roc"), @@ -1270,6 +1280,8 @@ mod cli_tests { #[cfg_attr(windows, ignore)] /// this tests that a platform can correctly import a package fn platform_requires_pkg() { + copy_zig_glue::initialize_zig_test_platforms(); + let cli_build = ExecCli::new( CMD_BUILD, file_from_root( diff --git a/crates/copy_zig_glue/src/lib.rs b/crates/copy_zig_glue/src/lib.rs index 52fdc74580..2552b6fb4a 100644 --- a/crates/copy_zig_glue/src/lib.rs +++ b/crates/copy_zig_glue/src/lib.rs @@ -6,11 +6,9 @@ use std::{fs, io}; static ZIG_PLATFORM_COPY_GLUE_ONCE: Once = Once::new(); /// 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 +/// this is only temporary, we should create a zig package for the test platforms pub fn initialize_zig_test_platforms() { ZIG_PLATFORM_COPY_GLUE_ONCE.call_once(|| { - dbg!("ZIG_PLATFORM_COPY_GLUE_ONCE"); - // initialization code here copy_zig_glue(); }); } @@ -20,9 +18,7 @@ pub fn initialize_zig_test_platforms() { /// This is a simple way to use these files without creating a zig package, /// to support the upgrade from zig 0.11.0 to 0.13.0, and keep the scope of the change smaller. /// -/// Once we have zig 0.13.0, and also removed platform/host rebuilding, we will need to upgrade the -/// test platforms so they produce their own host binaries, and this will be the best time to -/// upgrade to a zig package and can also be done incrementally withouth changing all the platforms in one go. +/// Once we have zig 0.13.0, we should add a zig package for the test platforms. pub fn copy_zig_glue() { let workspace_dir = roc_test_utils_dir::workspace_root(); let zig_builtins_source_dir = workspace_dir.join("crates/compiler/builtins/bitcode/src");