2009-10-09 74 views
5

我有一个脚本系统的make文件,有很多测试应该通过。每个测试是对脚本应用程序的单独调用:GNU 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 
    ... 

回答

8

使用!命令。

echo This returns success 
! echo This returns failure 
+1

具体而言,其“!斌/亲属”,而不是“!斌/亲属”,这是我尝试过,并得到一个错误 – 2009-10-09 20:53:56

+0

用grep时,测试的错误消息的在建日志输出存在非常有用的。 '! grep output.log -i“错误信息”' – shuckc 2013-10-11 16:52:23

1

假设你要确保的“斌/亲属test5.kin”退出状态为5.然后,只需这样写:

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

评估技术试验看到“助考”和“男人测试”。

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