diff options
author | Tristan Sloughter <t@crashfast.com> | 2018-10-06 18:52:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-06 18:52:20 -0600 |
commit | 763fd05a0f6be023a4f646c55ddd72ae193e350b (patch) | |
tree | d785184b18bcee2b83e527d7a72ec0f60c4d3cc4 | |
parent | 4d92f3c040680213127fc3faa9638e1cd34b50fa (diff) |
fix yrl compiler and add test (#1906)
-rw-r--r-- | src/rebar_compiler_yrl.erl | 2 | ||||
-rw-r--r-- | test/rebar_compile_SUITE.erl | 23 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/rebar_compiler_yrl.erl b/src/rebar_compiler_yrl.erl index 765ea36..41d93b1 100644 --- a/src/rebar_compiler_yrl.erl +++ b/src/rebar_compiler_yrl.erl @@ -34,7 +34,7 @@ compile(Source, [{_, OutDir}], _, Opts) -> AllOpts = [{parserfile, Target} | Opts], AllOpts1 = [{includefile, filename:join(OutDir, I)} || {includefile, I} <- AllOpts, filename:pathtype(I) =:= relative], - case yeec:file(Source, AllOpts1 ++ [{return, true}]) of + case yecc:file(Source, AllOpts1 ++ [{return, true}]) of {ok, _} -> ok; {ok, _Mod, Ws} -> diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index e97b5fb..867460c 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -832,19 +832,36 @@ dont_recompile_yrl_or_xrl(Config) -> "Erlang code.", ok = ec_file:write(Xrl, XrlBody), + Yrl = filename:join([AppDir, "src", "not_a_real_yrl_" ++ Name ++ ".yrl"]), + ok = filelib:ensure_dir(Yrl), + YrlBody = ["Nonterminals E T F.\n" + "Terminals '+' '*' '(' ')' number.\n" + "Rootsymbol E.\n" + "E -> E '+' T: {'$2', '$1', '$3'}.\n" + "E -> T : '$1'.\n" + "T -> T '*' F: {'$2', '$1', '$3'}.\n" + "T -> F : '$1'.\n" + "F -> '(' E ')' : '$2'.\n" + "F -> number : '$1'.\n"], + ok = ec_file:write(Yrl, YrlBody), + XrlBeam = filename:join([AppDir, "ebin", filename:basename(Xrl, ".xrl") ++ ".beam"]), + YrlBeam = filename:join([AppDir, "ebin", filename:basename(Yrl, ".yrl") ++ ".beam"]), rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}), - ModTime = filelib:last_modified(XrlBeam), + XrlModTime = filelib:last_modified(XrlBeam), + YrlModTime = filelib:last_modified(YrlBeam), timer:sleep(1000), rebar_test_utils:run_and_check(Config, [], ["compile"], {ok, [{app, Name}]}), - NewModTime = filelib:last_modified(XrlBeam), + NewXrlModTime = filelib:last_modified(XrlBeam), + NewYrlModTime = filelib:last_modified(YrlBeam), - ?assert(ModTime == NewModTime). + ?assert(XrlModTime == NewXrlModTime), + ?assert(YrlModTime == NewYrlModTime). delete_beam_if_source_deleted(Config) -> AppDir = ?config(apps, Config), |