Skip to content

Commit

Permalink
tests release modes
Browse files Browse the repository at this point in the history
  • Loading branch information
ityonemo committed Oct 20, 2024
1 parent 8635b3a commit 324de0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/zig/_module.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Zig.Module do
:c,
:dir,
:easy_c,
release_mode: :safe,
release_mode: :debug,
language: Elixir,
nifs: {:auto, []},
ignore: [],
Expand Down
4 changes: 4 additions & 0 deletions lib/zig/command.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ defmodule Zig.Command do
safe: "ReleaseSafe"
}

def release_mode(%{release_mode: :env}) do
System.fetch_env!("ZIGLER_RELEASE_MODE")
end

def release_mode(module) do
Map.fetch!(@release_modes, module.release_mode)
end
Expand Down
9 changes: 5 additions & 4 deletions test/corner_cases/release_mode_test.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
defmodule ZiglerTest.CornerCases.ReleaseMode do
use ExUnit.Case, async: true

release_mode = :debug

use Zig, otp_app: :zigler, release_mode: release_mode
use Zig, otp_app: :zigler, release_mode: :safe

~Z"""
pub fn add(a: u32, b: u32) u32 {
return a + b;
}
"""

test "release mode safe works" do
assert 48 = add(47, 1)
end
end

0 comments on commit 324de0a

Please sign in to comment.