Build custom database in test

This commit is contained in:
Jordan Bracco 2020-06-14 18:39:46 +02:00
parent 1d949c82ca
commit 6672860b19
2 changed files with 5 additions and 12 deletions

View file

@ -6,24 +6,16 @@ CFLAGS = -std=c99 -g -Wall -Werror
CPPFLAGS = -I$(ERL_EI_INCLUDE) CPPFLAGS = -I$(ERL_EI_INCLUDE)
LDFLAGS = -L$(ERL_EI_LIB) LDFLAGS = -L$(ERL_EI_LIB)
LDLIBS = -lpthread -lei -lm -lmagic LDLIBS = -lpthread -lei -lm -lmagic
BEAM_FILES = _build/
PRIV = priv/ PRIV = priv/
RM = rm -Rf RM = rm -Rf
# Unit test custom magic file all: priv/apprentice
MAGIC = file
all: priv/apprentice test/elixir.mgc
test/%.mgc: test/%
cd test; file -C -m ../$^
priv/apprentice: src/apprentice.c priv/apprentice: src/apprentice.c
mkdir -p priv mkdir -p priv
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
clean: clean:
$(RM) $(PRIV) $(BEAM_FILES) test/*.mgc $(RM) $(PRIV)
.PHONY: clean .PHONY: clean

View file

@ -42,8 +42,9 @@ defmodule GenMagicTest do
end end
test "Custom database file recognises Elixir files" do test "Custom database file recognises Elixir files" do
database = absolute_path("test/elixir.mgc") database = absolute_path("elixir.mgc")
IO.puts("Database: #{inspect(database)} #{inspect(File.exists?(database))}") on_exit(fn() -> File.rm(database) end)
{_, 0} = System.cmd("file", ["-C", "-m", absolute_path("test/elixir")])
{:ok, pid} = GenMagic.Server.start_link(database_patterns: [database]) {:ok, pid} = GenMagic.Server.start_link(database_patterns: [database])
path = absolute_path("mix.exs") path = absolute_path("mix.exs")
assert {:ok, %Result{} = result} = GenMagic.Server.perform(pid, path) assert {:ok, %Result{} = result} = GenMagic.Server.perform(pid, path)