Skip to content

Commit

Permalink
Merge pull request #168 from kubkon/macho-tests-on-nix
Browse files Browse the repository at this point in the history
Clean up tests so that they can run on a Nix host
  • Loading branch information
kubkon authored Dec 26, 2024
2 parents a6fcf0b + 4df4a09 commit 1b5fbc5
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 212 deletions.
2 changes: 2 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub fn build(b: *std.Build) void {
const has_zig = b.option(bool, "has-zig", "Whether the Zig compiler is in path") orelse false;
const is_musl = b.option(bool, "musl", "Whether the tests are linked against musl libc") orelse false;
const has_objc_msgsend_stubs = b.option(bool, "has-objc-msgsend-stubs", "Whether the system compiler supports '-fobjc-msgsend-selector-stubs' flag") orelse false;
const is_nix = b.option(bool, "nix", "Whether the host is Nix-based") orelse false;

const unit_tests = b.addTest(.{
.root_source_file = b.path("src/Ld.zig"),
Expand All @@ -114,6 +115,7 @@ pub fn build(b: *std.Build) void {
.has_zig = has_zig,
.is_musl = is_musl,
.has_objc_msgsend_stubs = has_objc_msgsend_stubs,
.is_nix = is_nix,
}));
}

Expand Down
6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@
version = "master";
src = ./.;
nativeBuildInputs = commonInputs;
buildInputs = commonInputs;
dontConfigure = true;
dontInstall = true;
doCheck = false; # TODO enable this
doCheck = true;
buildPhase = ''
mkdir -p .cache
zig build install -Doptimize=ReleaseFast --prefix $out --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache
'';
# TODO why -Dhas-zig doesn't work?
checkPhase = ''
zig build test -Dhas-zig --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache
zig build test -Dnix --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache
'';
};

Expand Down
Loading

0 comments on commit 1b5fbc5

Please sign in to comment.