How to get GNU to explicitly test a bug?

After many years when I did not use make, I again need this, the gnu version. I’m sure that I can do what I want, but I don’t understand how, or found an answer from Google, etc.

I am trying to create a test object that will run my program several times, storing the results in a log file. Some tests should interrupt my program. Unfortunately, my makefile is aborted on the first test, which leads to an error. I have something like:

# Makefile # test: myProg -h > test.log # Display help myProg good_input >> test.log # should run fine myProg bad_input1 >> test.log # Error 1 myProg bad_input2 >> test.log # Error 2 

With the above, shut down after running bad_input1, never before running bad_input2.

+62
makefile gnu-make
Feb 02 2018-10-02T00
source share
3 answers

The right decision, if you want the target to fail, is to deny its exit code.

 # Makefile # test: myProg -h > test.log # Display help myProg good_input >> test.log # should run fine ! myProg bad_input1 >> test.log # Error 1 ! myProg bad_input2 >> test.log # Error 2 

Now in these two cases it will be a mistake.

+16
Feb 21 '14 at 13:24
source share

Put a - in front of the command, for example:

 -myProg bad_input >> test.log 

GNU make will ignore the process exit code.

+120
02 Feb 2018-10-02T00
source share

Try running it like

 make -i 

or

 make --ignore-errors 

which ignores all errors in all rules .

I also suggest running it as

 make -i 2>&1 | tee results 

so that you get all the errors and the conclusion to find out what happened.

Just continuing blindly after an error is probably not what you really want to do. The make utility, by its very nature, usually relies on the successful completion of previous commands, so that it can use the artifacts of these commands as prerequisites for commands that will be executed later.

BTW I would highly recommend getting a copy

+30
Feb 02 '10 at 23:09
source share



All Articles