Skip to content

Commit 4a8cd91

Browse files
committed
ci: run tests with and without the Erlang allocator
The allocator is selected when the NIF loads, so exercise both modes in CI via EXQLITE_DISABLE_ERLANG_ALLOCATOR. Test config reads that env var, and the allocator test asserts the NIF matches the configured setting.
1 parent b7da445 commit 4a8cd91

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,11 @@ jobs:
8080
- run: mix deps.get --only test
8181
- run: mix deps.compile
8282
- run: mix compile
83-
- run: mix test
83+
- name: Test with Erlang allocator
84+
run: mix test
85+
env:
86+
EXQLITE_DISABLE_ERLANG_ALLOCATOR: "false"
87+
- name: Test without Erlang allocator
88+
run: mix test
89+
env:
90+
EXQLITE_DISABLE_ERLANG_ALLOCATOR: "true"

‎config/config.exs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Config
2+
3+
if config_env() == :test do
4+
disable_erlang_allocator =
5+
case System.get_env("EXQLITE_DISABLE_ERLANG_ALLOCATOR") do
6+
nil -> false
7+
value -> String.downcase(value) in ~w(true 1)
8+
end
9+
10+
config :exqlite, disable_erlang_allocator: disable_erlang_allocator
11+
end

‎test/exqlite/allocator_test.exs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
defmodule Exqlite.AllocatorTest do
22
use ExUnit.Case
33

4-
test "erlang allocator is used by default" do
5-
assert Application.get_env(:exqlite, :disable_erlang_allocator) == nil
6-
assert Exqlite.Sqlite3NIF.erlang_allocator_enabled()
4+
test "erlang allocator respects configuration" do
5+
disabled = Application.get_env(:exqlite, :disable_erlang_allocator, false)
6+
7+
assert is_boolean(disabled)
8+
assert Exqlite.Sqlite3NIF.erlang_allocator_enabled() == not disabled
79
end
810
end

0 commit comments

Comments
 (0)