From 83963cb1f7302bc552c89d50dba092d44d5180d2 Mon Sep 17 00:00:00 2001 From: Stanislaw Klekot Date: Sat, 29 Oct 2016 00:15:19 +0200 Subject: [PATCH] Added $PROJECT_ROOT/src to include path. --- bin/estap | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/estap b/bin/estap index d4e080d..1aa8f0a 100755 --- a/bin/estap +++ b/bin/estap @@ -8,12 +8,15 @@ main(["--help"]) -> io:fwrite("Usage: ~s filename~n", [escript:script_name()]); main([File]) -> - {ok, {_Module, Forms}} = estap_file:read_file(File, []), - {ok, {Plan, Tests}} = estap_file:load_code(Forms), - case find_ebin(File) of - {ok, Path} -> code:add_patha(Path); - nothing -> ok + case find_project_root(File) of + {ok, Path} -> + IncludeDirs = [filename:join(Path, src)], + code:add_patha(filename:join(Path, ebin)); + nothing -> + IncludeDirs = [] end, + {ok, {_Module, Forms}} = estap_file:read_file(File, IncludeDirs), + {ok, {Plan, Tests}} = estap_file:load_code(Forms), estap_test:run(Plan, Tests), ok. @@ -21,16 +24,15 @@ main([File]) -> -include_lib("kernel/include/file.hrl"). -find_ebin(Path) -> - EBin = filename:join(Path, ebin), - case file:read_file_info(EBin) of +find_project_root(Path) -> + case file:read_file_info(filename:join(Path, ebin)) of {ok, #file_info{type = directory}} -> - {ok, EBin}; + {ok, Path}; _ -> case Path of "." -> nothing; % don't check parent "/" -> nothing; % no parent - _ -> find_ebin(filename:dirname(Path)) + _ -> find_project_root(filename:dirname(Path)) end end. -- 1.7.10.4