Skip to content

Commit

Permalink
run slow and fast tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Aug 17, 2023
1 parent 6bd1277 commit f086208
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion +bids/+internal/is_github_ci.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% (C) Copyright 2021 Remi Gau
is_github = false;

GITHUB_WORKSPACE = getenv('HOME');
GITHUB_WORKSPACE = bg;
IS_CI = getenv('CI');

if IS_CI
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/run_tests_matlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
matrix:
version: [R2021a, R2023a]
os: [ubuntu-latest, macos-latest, windows-latest]
test: [slow, fast]


runs-on: ${{matrix.os}}
Expand Down Expand Up @@ -61,6 +62,10 @@ jobs:
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
git clone https://github.com/MOcov/MOcov.git --depth 1
- name: set environment variable
if: matrix.test == 'slow'
run: export SLOW=true

- name: Run commands
uses: matlab-actions/[email protected]
with:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/run_tests_octave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ env:
jobs:
test:

strategy:
fail-fast: false
matrix:
test: [slow, fast]

runs-on: ubuntu-22.04

steps:
Expand Down Expand Up @@ -70,6 +75,10 @@ jobs:
mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS
octave $OCTFLAGS --eval "addpath(fullfile(pwd)); savepath();"
- name: set environment variable
if: matrix.test == 'slow'
run: export SLOW=true

- name: Run unit tests Octave
run: |
octave $OCTFLAGS --eval "success = run_tests(); assert(success);"
5 changes: 4 additions & 1 deletion run_tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
addpath(fullfile(pwd, 'tests', 'utils'));

folderToCover = fullfile(pwd, '+bids');

testFolder = fullfile(pwd, 'tests');
if run_slow_test_only
testFolder = fullfile(pwd, 'tests', 'tests_slow');
end

if with_coverage
success = moxunit_runtests(testFolder, ...
'-verbose', ...
'-randomize_order', ...
'-recursive', ...
'-with_coverage', ...
'-cover', folderToCover, ...
Expand Down
53 changes: 53 additions & 0 deletions tests/tests_slow/test_download_ds.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
function test_suite = test_download_ds %#ok<*STOUT>

try % assignment of 'localfunctions' is necessary in Matlab >= 2016
test_functions = localfunctions(); %#ok<*NASGU>
catch % no problem; early Matlab versions can use initTestSuite fine
end
initTestSuite;

end

function test_download_ds_moae()

if ~run_slow_test_only()
moxunit_throw_test_skipped_exception('slow test only');
end

output_dir = bids.util.download_ds('source', 'spm', ...
'demo', 'moae', ...
'out_path', temp_dir(), ...
'force', false, ...
'verbose', true, ...
'delete_previous', false);

output_dir = bids.util.download_ds('source', 'spm', ...
'demo', 'moae', ...
'out_path', temp_dir(), ...
'force', true, ...
'verbose', true, ...
'delete_previous', false);

output_dir = bids.util.download_ds('source', 'spm', ...
'demo', 'moae', ...
'out_path', temp_dir(), ...
'force', true, ...
'verbose', true, ...
'delete_previous', true);

end

function test_download_ds_facerep()

if ~run_slow_test_only()
moxunit_throw_test_skipped_exception('slow test only');
end

output_dir = bids.util.download_ds('source', 'spm', ...
'demo', 'facerep', ...
'out_path', temp_dir(), ...
'force', true, ...
'verbose', true, ...
'delete_previous', true);

end
8 changes: 8 additions & 0 deletions tests/utils/run_slow_test_only.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function value = run_slow_test_only()
% (C) Copyright 2023 BIDS-MATLAB developers
SLOW = getenv('SLOW');
value = false;
if ~isempty(SLOW)
value = true;
end
end

0 comments on commit f086208

Please sign in to comment.