Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU make: inverting sub-process success?

I've a make file for a scripted system, with a lot of tests which should pass. Each test is a separate call to the scripting application:

#----------------------------------------------------------------------------
# run test scripts in the module::test
#----------------------------------------------------------------------------
scripted_tests: bin/kin modules/test/actor_equality.kin modules/test/actor_fibre.kin ...
    bin/kin modules/test/actor_equality.kin
    bin/kin modules/test/actor_fibre.kin
    ...

Which is fine. I also have some similar tests which should return failure. I know that - will ignore the return status, but there must be something simple to invert the return status so I can run

#----------------------------------------------------------------------------
# run test scripts in the module::test::errors
#----------------------------------------------------------------------------
inverse_tests: bin/kin modules/test/error/bad_function.kin ...
    not bin/kin modules/test/error/bad_function.kin
    ...
like image 807
Pete Kirkham Avatar asked Oct 09 '09 20:10

Pete Kirkham


2 Answers

Use the ! command.

echo This returns success
! echo This returns failure
like image 123
dave4420 Avatar answered Oct 16 '22 20:10

dave4420


Suppose you want to make sure that the exit status of "bin/kin test5.kin" is 5. Then just write this:

run-test5:
  bin/kin test5.bin; test $$? = 5

For more elaborated tests see 'help test' and 'man test'.

Note: I tend to avoid exclamation marks because it is typically impossible to copy/paste them into an interactive shell (since it searches the history).

like image 31
MarcH Avatar answered Oct 16 '22 18:10

MarcH