【问题标题】:Detect if Jasmine failed via Bash检测 Jasmine 是否通过 Bash 失败
【发布时间】:2015-12-17 04:26:45
【问题描述】:

我正在我的 Web 应用程序中运行 Jasmine 测试,我想创建一个 bash 脚本来运行测试并将当前代码推送到远程 git 存储库(如果没有失败)。除了我不知道测试是成功还是失败之外,一切都是超级骗子。我该怎么做?如果在 bash 中无法做到,我可以在 python 或 nodejs 中做到。

我希望代码如下所示:

#!/bin/bash
succeeded=$(grunt test -no_output) #or some thing like it

if[ succeeded = 'True'] than
    git push origin master
fi

【问题讨论】:

    标签: python node.js bash gruntjs karma-jasmine


    【解决方案1】:

    运行命令然后查看$?。示例:

    if [ $? -eq 0 ]
    then
      echo "Successfully created file"
    else
     echo "Could not create file" >&2
    fi
    

    【讨论】:

      【解决方案2】:

      看起来像grunt uses exit codes 表示任务是否成功。你可以用它来判断是否推送:

      if grunt test -no_output; then
          git push origin master
      fi
      

      这会测试来自 grunt 的 0(成功)退出代码,如果收到则推送。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-26
        • 1970-01-01
        • 1970-01-01
        • 2013-08-30
        相关资源
        最近更新 更多