Nimbin[12]?Mirrors & Forks / syntastic / commits / fbaf3dc7

syntastic git · master

syntastic vim plugin (fork)

vim fork · first commit 2009-07-10 · last commit 2022-07-10 (4 years ago) · synced 3 days ago · upstream: github.com/vim-syntastic/syntastic

Vim Script 99%
git clone https://git.christianimmanuel.de/mirrors-forks/syntastic.gitwget https://git.christianimmanuel.de/mirrors-forks/syntastic/archive/syntastic.tar.gz

Fix Erlang checker for test files with no test cfg

Nick Marino · 2021-07-19 14:19 · fbaf3dc70d7240c5fc68830baa04b357457413eb

If we're editing a file in the "test" directory, the syntax checker
assumes we should use the 'test' profile and attempts to read from
"rebar.test.config" instead of "rebar.config". However, it is common to
have Erlang projects with tests that don't necessarily use a separate
"rebar.test.config" file, and in those types of projects the syntax
checker will break. This patch handles this case by falling back to
using "rebar.config" for tests if a separate "rebar.test.config" file is
not found.
 syntax_checkers/erlang/erlang_check_file.erl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/syntax_checkers/erlang/erlang_check_file.erl b/syntax_checkers/erlang/erlang_check_file.erl
index 0dc01658..f25e73eb 100755
--- a/syntax_checkers/erlang/erlang_check_file.erl
+++ b/syntax_checkers/erlang/erlang_check_file.erl
@@ -61,7 +61,15 @@ which_build_tool(Dir, Profile) ->
     end.
 
 rebar_file(Dir, normal) -> filename:join(Dir, "rebar.config");
-rebar_file(Dir, test)   -> filename:join(Dir, "rebar.test.config").
+rebar_file(Dir, test)   ->
+    TestConfig = filename:join(Dir, "rebar.test.config"),
+    case filelib:is_file(TestConfig) of
+        true ->
+            TestConfig;
+        false ->
+            %% If we can't find "rebar.test.config" try falling back:
+            rebar_file(Dir, normal)
+    end.
 
 erlangmk_file(Dir) -> filename:join(Dir, "erlang.mk").