Skip to content

Commit 3a1269e

Browse files
authored
Merge pull request #62 from Remi-Gau/remi-Mox_unit_test
Set up MOxunit and MOcov
2 parents ac5dd0c + 14baca8 commit 3a1269e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+662
-414
lines changed

.github/workflows/moxunit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches: '*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: true
17+
fetch-depth: 1
18+
- name: MOxUnit Action
19+
uses: joergbrech/[email protected]
20+
with:
21+
tests: tests
22+
src: src
23+
with_coverage: true
24+
cover_xml_file: coverage.xml
25+
- name: Code coverage
26+
uses: codecov/codecov-action@v1
27+
with:
28+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
29+
file: coverage.xml # optional
30+
flags: unittests # optional
31+
name: codecov-umbrella # optional
32+
fail_ci_if_error: true # optional (default = false)

.gitignore

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
1+
# exclude mac file
22
*DS_Store
33

4+
# exclude matlab autosaves and octave workspace info
45
*.m~
56
*octave-workspace
67

78
# exclude content of logfiles folders
9+
tests/output/*
10+
manualTests/output/*
11+
output/*
812
*.tsv
913
*.mat
1014

11-
check_my_code_report.txt
15+
# exclude temp files from tests and coverage
16+
tests/coverage*
17+
tests/test_code_report.txt
1218
test_code_report.txt
1319

14-
output/**
20+
# exclude report from check_my_code
21+
check_my_code_report.txt
22+
23+
24+
25+

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ install:
2929
- sudo npm install -g bids-validator
3030

3131
before_script:
32+
# Add to src functions to path
33+
- octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath ();"
3234
# Change current directory
33-
- cd tests
35+
- cd manualTests
3436

3537
jobs:
3638
include:
37-
- stage: "Tests"
38-
name: "Unit and integration Tests"
39-
script: octave $OCTFLAGS --eval "results = runTests; assert(all(~[results.Failed]))"
39+
# - stage: "Tests"
40+
# name: "Unit and integration Tests"
41+
# script: octave $OCTFLAGS --eval "results = runTests; assert(all(~[results.Failed]))"
4042
- stage: "BIDS validator"
4143
name: "Create and check dataset"
42-
script: cd manualTests && octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/rawdata/ --ignoreNiftiHeaders
44+
script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/rawdata/ --ignoreNiftiHeaders
4345
- stage: "Linter"
4446
name: "miss_hit"
4547
script: cd .. && mh_style `pwd`

checkCppBidsDependencies.m

Lines changed: 0 additions & 27 deletions
This file was deleted.
File renamed without changes.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function test_suite = test_createDataDictionary %#ok<*STOUT>
2+
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
3+
test_functions = localfunctions(); %#ok<*NASGU>
4+
catch % no problem; early Matlab versions can use initTestSuite fine
5+
end
6+
initTestSuite;
7+
end
8+
9+
function test_createDataDictionaryBasic()
10+
11+
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
12+
13+
%% set up
14+
15+
cfg.verbose = false;
16+
17+
cfg.subject.subjectNb = 1;
18+
cfg.subject.runNb = 1;
19+
20+
cfg.task.name = 'testtask';
21+
22+
cfg.dir.output = outputDir;
23+
24+
cfg.testingDevice = 'mri';
25+
26+
cfg = createFilename(cfg);
27+
28+
logFile.extraColumns.Speed.length = 1;
29+
logFile.extraColumns.LHL24.length = 3;
30+
logFile = saveEventsFile('init', cfg, logFile);
31+
32+
createDataDictionary(cfg, logFile);
33+
34+
%% check that the file has the right path and name
35+
36+
% data to test against
37+
funcDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'func');
38+
39+
jsonFilename = ['sub-001_ses-001_task-testtask_run-001_events_date-' ...
40+
cfg.fileName.date '.json'];
41+
42+
% test
43+
assertTrue(exist(fullfile(funcDir, jsonFilename), 'file') == 2);
44+
45+
%% check content
46+
actualStruct = bids.util.jsondecode(fullfile(funcDir, jsonFilename));
47+
48+
% data to test against
49+
expectedStruct = bids.util.jsondecode( ...
50+
fullfile(pwd, 'testData', 'eventsDataDictionary.json'));
51+
52+
% test
53+
assertTrue(isequal(expectedStruct, actualStruct));
54+
55+
end

tests/manualTests/test_makeRawDataset.m renamed to manualTests/test_makeRawDataset.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
function test_makeRawDataset()
22

3-
fprintf('\n\n--------------------------------------------------------------------\n\n');
4-
5-
clear;
6-
73
outputDir = fullfile(fileparts(mfilename('fullpath')), 'output');
84

95
if isdir(outputDir)
@@ -16,7 +12,9 @@ function test_makeRawDataset()
1612

1713
cfg.subject.subjectNb = 1;
1814
cfg.subject.runNb = 1;
15+
1916
cfg.task.name = 'testtask';
17+
2018
cfg.dir.output = outputDir;
2119

2220
cfg.bids.datasetDescription.Name = 'dummy';
@@ -77,7 +75,7 @@ function test_makeRawDataset()
7775
funcDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001', 'func');
7876
boldFilename = 'sub-001_ses-001_task-testtask_run-001_bold.nii.gz';
7977
copyfile( ...
80-
fullfile('..', '..', 'dummyData', 'dummyData.nii.gz'), ...
78+
fullfile('..', 'dummyData', 'dummyData.nii.gz'), ...
8179
fullfile(funcDir, boldFilename));
8280

8381
%%
File renamed without changes.

printCreditsCppBids.m

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)