-
Notifications
You must be signed in to change notification settings - Fork 296
avoid pre-compile time errors in expand_include_lib_path #485
Conversation
Thanks. Do you mind extending the commit message with a previously broken include_lib directive? |
No problem. Done. |
This probably warrants a debug log msg. |
ok |
Tested the changes and the pull request works here. Thanks @Tuncer. |
[Lib | Parts] = filename:split(filename:dirname(File)), | ||
SubDir = case Parts of | ||
[] -> % prevent function clause error | ||
[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to print the debug msg here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably yes. I have pushed an updated version.
@kejv should we have tests to go with this? |
Are we able to tell whether compilation failed because of rebar internal error or compile time error (I am thinking of retest_sh:run/2)? |
On Tue, May 5, 2015 at 8:03 PM, kejv wrote:
Scanning the error output from run/2 would be the usual way. |
Compare the rebar errors produced by 1) erlc, 2) rebar itself:
I don't think there's any sane way how to test the difference (and I don't consider scanning the strings in the list with regex as sane). |
Doesn't that mean we should (1) print a more informative error in erlc_compiler, and (2) can't we scan for the ?DEBUG message? |
(1) No, since we don't print any error message at all in erlc_compiler. Quite the contrary actually, we want to try to avoid any errors. Moreover, I really start thinking that printing the debug message is not such a good idea. Because it will print for e.g. |
I agree, but as we're treating the included header as a dependency, shouldn't we at least log a DEBUG msg on ENOFILE? |
Note that at this stage we don't know yet whether the header is a dependency for rebar logic (erlcinfo). This will be decided only in expand_file_names/2 based on content of Dirs variable. Generally I think there's no reason to duplicate the work of erlc. If the header file doesn't exist erlc will throw an error anyway. |
But don't we already do the check before updating the digraph? |
No. We collect all included headers (in process_attr) and then filter out those which are not in the include path (in expand_file_names) and this will typically filter out all include_lib files.
Still this is the strongest reason why rebar should not try to check existence of files, yet even printing some related debug messages. |
Okay. Let's add the previously crashing scenario as a regression test and merge this. |
Previously when user specified broken include_lib, such as -include_lib("my_app.hrl"), the code throwed too early exception. We fix this simply by avoiding any possible internal errors, possibly letting even nonsensical paths pass. These will be checked and filtered later in expand_file_names/2.
Until |
Having fixed the rebar-internal error, why can't we (1) expect run/2 failure AND (2) scan for |
You mean something like this?
This seems quite hacky to me. And moreover it is also fragile. What if someone decides that he really wants that debugging message (which I didn't) and formulates it in exactly the same way as erlc? Then if he breaks the code the test will still pass. Or what if erlc for some reason changes the error message? Frankly, I would rather have no tests at all than tests with potential of false negatives or positives. |
Something like that or inttest/logging. If someone adds that debug msg, the test would have to be adapted. Also, looking for a less specific error msg and having a minimal module that's unable to provoke any other error should make the scan resilient against changes in compile:file. However, the missing test is not important enough to hold up the patch. So, I'm okay without it. |
Uh yeah, so that +7-3 patch seems good then. Merging. |
avoid pre-compile time errors in expand_include_lib_path
No description provided.