【问题标题】:Build Status from Matlab using Drone使用 Drone 从 Matlab 构建状态
【发布时间】:2016-04-09 05:31:13
【问题描述】:

我使用 Drone 作为持续集成 (CI) 服务器。

使用此脚本开始测试:

image: drone/matlab:R2014a
script:
    - cd test
    - matlab -nodesktop -nosplash -r ci_run_tests

notify:
    email:
        on_failure: blame

函数 ci_run_tests 就是基于这个答案: https://stackoverflow.com/a/23347768

对于 Jenkins,作者建议将测试结果写入 *.tap 文件,在我的例子中是这样的:

1..4
ok 1 - test_annotation_to_pitch/test_with_systematic_scale
ok 2 - test_audio_to_pitch/test_120_vs_360
not ok 3 - test_pitch_to_CENS/test_12_vs_36
ok 4 - test_pitch_to_chroma/test_12_vs_36

测试 3 失败。 Drone 不知道这些信息,因为它不解释那些 *.tap 文件,它只注册了 Matlab 正确退出 - 因此说构建本身可以工作。

我的问题: Drone 是否支持某种功能,例如 Jenkins 中的 *.tap 文件

谢谢!

【问题讨论】:

标签: matlab continuous-integration drone.io


【解决方案1】:

大多数持续集成系统不会解析结果或知道正在使用的测试,而是检查被调用程序的退出状态。

要发出错误信号,程序需要退出0

虽然提到的测试脚本有一个exit(1),但似乎testrunner 在测试失败时不会引发异常。因此,要检查失败的测试,您需要计算它们的数量:

function runAllMyTests

import matlab.unittest.TestSuite;
import matlab.unittest.TestRunner;
import matlab.unittest.plugins.TAPPlugin;
import matlab.unittest.plugins.ToFile;

try
    % Create the suite and runner
    suite = TestSuite.fromPackage('packageThatContainsTests', 'IncludingSubpackages', true);
    runner = TestRunner.withTextOutput;

    % Add the TAPPlugin directed to a file in the Jenkins workspace
    tapFile = fullfile(getenv('WORKSPACE'), 'testResults.tap');
    runner.addPlugin(TAPPlugin.producingOriginalFormat(ToFile(tapFile)));

    results = runner.run(suite);

    % Count number of failed tests. Exit(1) if greater than 0
    if nnz([results.Failed])
        exit(1);
    end
catch e;
    disp(e.getReport);
    exit(1);
end;
exit force;

当您考虑它时,这就是您真正想要的行为:异常总是会停止执行抛出它的任何事情。因此,您的测试套件会在第一次遇到错误时停止,不会显示任何其他错误。

【讨论】:

    【解决方案2】:

    drone 是否支持 JUnit 风格的 XML 工件?如果是这样,那么另一种解决方案是为 MATLAB Unit TestRunner 使用 XMLPlugin 而不是 TAPPlugin。

    【讨论】:

      猜你喜欢
      • 2018-02-18
      • 1970-01-01
      • 2012-07-15
      • 1970-01-01
      • 2017-07-11
      • 2020-04-14
      • 1970-01-01
      • 2016-12-07
      • 2013-02-26
      相关资源
      最近更新 更多