Makefile GNU make:反转子流程成功?

Makefile GNU make:反转子流程成功?,makefile,gnu-make,Makefile,Gnu Make,我有一个脚本系统的make文件,有很多测试应该通过。每个测试都是对脚本应用程序的单独调用: #---------------------------------------------------------------------------- # run test scripts in the module::test #---------------------------------------------------------------------------- scripted_

我有一个脚本系统的make文件,有很多测试应该通过。每个测试都是对脚本应用程序的单独调用:

#----------------------------------------------------------------------------
# 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
    ...
这很好。我也有一些类似的测试,应该返回失败。我知道
-
将忽略返回状态,但必须有一些简单的方法来反转返回状态,以便我可以运行

#----------------------------------------------------------------------------
# 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
    ...

使用
命令

echo This returns success
! echo This returns failure

假设您希望确保“bin/kin test5.kin”的退出状态为5。然后写下:

run-test5:
  bin/kin test5.bin; test $$? = 5
有关更详细的测试,请参阅“帮助测试”和“人工测试”


注意:我倾向于避免使用感叹号,因为通常不可能将它们复制/粘贴到交互式shell中(因为它会搜索历史记录)。

特别是,它的“!bin/kin”而不是“!bin/kin”,我尝试过它,但在使用grep测试生成日志输出中是否存在错误消息时,得到了一个非常有用的错误<代码>!grep output.log-i“error msg”