From 6672860b1990f6b7fe478b60223a64c6f606d8cc Mon Sep 17 00:00:00 2001 From: Jordan Bracco Date: Sun, 14 Jun 2020 18:39:46 +0200 Subject: [PATCH] Build custom database in test --- Makefile | 12 ++---------- test/gen_magic/gen_magic_test.exs | 5 +++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index cb2e93d..cbd6fec 100644 --- a/Makefile +++ b/Makefile @@ -6,24 +6,16 @@ CFLAGS = -std=c99 -g -Wall -Werror CPPFLAGS = -I$(ERL_EI_INCLUDE) LDFLAGS = -L$(ERL_EI_LIB) LDLIBS = -lpthread -lei -lm -lmagic -BEAM_FILES = _build/ PRIV = priv/ RM = rm -Rf -# Unit test custom magic file - -MAGIC = file - -all: priv/apprentice test/elixir.mgc - -test/%.mgc: test/% - cd test; file -C -m ../$^ +all: priv/apprentice priv/apprentice: src/apprentice.c mkdir -p priv $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ clean: - $(RM) $(PRIV) $(BEAM_FILES) test/*.mgc + $(RM) $(PRIV) .PHONY: clean diff --git a/test/gen_magic/gen_magic_test.exs b/test/gen_magic/gen_magic_test.exs index 1b9a329..9699177 100644 --- a/test/gen_magic/gen_magic_test.exs +++ b/test/gen_magic/gen_magic_test.exs @@ -42,8 +42,9 @@ defmodule GenMagicTest do end test "Custom database file recognises Elixir files" do - database = absolute_path("test/elixir.mgc") - IO.puts("Database: #{inspect(database)} #{inspect(File.exists?(database))}") + 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]) path = absolute_path("mix.exs") assert {:ok, %Result{} = result} = GenMagic.Server.perform(pid, path)