Skip to content

Commit

Permalink
use initialize_zig_test_platforms in all cli_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewilliamboswell committed Nov 12, 2024
1 parent f445172 commit f830447
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 12 additions & 0 deletions crates/cli/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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(
Expand All @@ -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"),
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 2 additions & 6 deletions crates/copy_zig_glue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand All @@ -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");
Expand Down

0 comments on commit f830447

Please sign in to comment.