diff --git a/+tests/runTest.m b/+tests/runTest.m new file mode 100644 index 0000000000000000000000000000000000000000..0fe22203b01d4eede6ebc78cdb52b6751800a6f2 --- /dev/null +++ b/+tests/runTest.m @@ -0,0 +1,19 @@ +function [exitCode] = runTest(fcnHandle) +%RUNTEST Runs the test function that is specified in the given filename + +exitCode = 0; + +try + fcnHandle(); + disp("Test " + func2str(fcnHandle) + " successful!"); +catch err + disp("------- ERROR -------"); + disp("Test failed for " + func2str(fcnHandle)); + disp("Error message:"); + disp(err); + exitCode = 1; +end + + + +end diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..c5d59e6b3d1ff401838e290fa9d166bbd2bab0b1 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,6 @@ +before_script: + +artoa3: + script: + - "ci/run_matlab_tests.sh" + diff --git a/ci/runAll.m b/ci/runAll.m new file mode 100644 index 0000000000000000000000000000000000000000..c488183eddf9f182e178a7abf8ebb43f00b787df --- /dev/null +++ b/ci/runAll.m @@ -0,0 +1,23 @@ +% ARTOA3 automatic test script +% This script is used by gitlab's ci feature for automated testing. +% Can also be used locally. + +[currentDirectory, ~, ~] = fileparts(mfilename('fullpath')); +addpath(genpath(fullfile(currentDirectory, '..'))); + +testsToRun = { ... + @tests.rfb.load, ... + @tests.ric.save, ... + @tests.soundsource.load ... +}; + +aTestFailed = 0; + +for i = 1:length(testsToRun) + exitCode = tests.runTest(testsToRun{i}); + if exitCode == 1 + aTestFailed = exitCode; + end +end + +exit(aTestFailed); \ No newline at end of file diff --git a/ci/run_matlab_tests.sh b/ci/run_matlab_tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..95fd9382f000301c2f04705e628b00c75e5d543f --- /dev/null +++ b/ci/run_matlab_tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +LOGFILE=lastTestRun.txt +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +matlab -nodesktop -nosplash -logfile "$DIR/$LOGFILE" -r "run('$DIR/runAll.m');"; +CODE=$? + +cat "$DIR/$LOGFILE" + +exit $CODE