Build custom database in test
This commit is contained in:
parent
87415c4854
commit
22024701a5
2 changed files with 5 additions and 11 deletions
12
Makefile
12
Makefile
|
@ -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
|
||||||
|
|
|
@ -42,7 +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")
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in a new issue