diff --git a/.travis.yml b/.travis.yml index 87c8f835..31d8dde4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_script: # Add to src functions to path - octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath ();" # Change current directory - - cd manualTests + - cd tests/manualTests jobs: include: diff --git a/manualTests/miss_hit.cfg b/manualTests/miss_hit.cfg deleted file mode 100644 index d86aaeb0..00000000 --- a/manualTests/miss_hit.cfg +++ /dev/null @@ -1,9 +0,0 @@ -# style guide (https://florianschanda.github.io/miss_hit/style_checker.html) -line_length: 100 -regex_function_name: "((test_[a-z]+)|[a-z]+)(([A-Z]){1}[A-Za-z]+)*" - -# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html) -metric "cnest": limit 4 -metric "file_length": limit 500 -metric "cyc": limit 15 -metric "parameters": limit 5 \ No newline at end of file diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index edb6dcaf..6a35504c 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -23,17 +23,13 @@ function convertSourceToRaw(cfg) rawDir = fullfile(cfg.dir.output, 'raw'); % add dummy README and CHANGE file - copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... - 'README'), ... + templateFolder = fullfile(fileparts(mfilename('fullpath')), '..', 'templates'); + + copyfile(fullfile(templateFolder, 'README'), ... sourceDir); - copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... - 'CHANGES'), ... + copyfile(fullfile(templateFolder, 'CHANGES'), ... sourceDir); - copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... - '.bidsignore'), ... + copyfile(fullfile(templateFolder, '.bidsignore'), ... sourceDir); copyfile(sourceDir, rawDir); diff --git a/src/templates/test_templateTest.m b/src/templates/test_templateTest.m index 73b91769..b293a352 100644 --- a/src/templates/test_templateTest.m +++ b/src/templates/test_templateTest.m @@ -23,6 +23,8 @@ function test_templateTestBasic() % expectedOuput = X; % assertEqual(actualOupout, expectedOuput) + % assertTrue( ); + % assertFalse( ); %% clean up (delete temporary files that were created) diff --git a/manualTests/dummyData/.bidsignore b/templates/.bidsignore similarity index 100% rename from manualTests/dummyData/.bidsignore rename to templates/.bidsignore diff --git a/manualTests/dummyData/CHANGES b/templates/CHANGES similarity index 100% rename from manualTests/dummyData/CHANGES rename to templates/CHANGES diff --git a/manualTests/dummyData/README b/templates/README similarity index 100% rename from manualTests/dummyData/README rename to templates/README diff --git a/manualTests/dummyData/dummyData.nii.gz b/templates/dummyData.nii.gz similarity index 100% rename from manualTests/dummyData/dummyData.nii.gz rename to templates/dummyData.nii.gz diff --git a/tests/README.md b/tests/README.md index 9d8452e4..c4ee1b18 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,23 +6,43 @@ - Install [MOcov for matlab and octave](https://github.com/MOcov/MOcov) to get the code coverage -- Make sure you are in the `tests` directory. +- Make sure the following folders and sub-folders are in the Octave / MATLAB + path: -- Run `moxunit_runtests` or `moxunit_runtests -verbose` to run the tests. + - `src` + - `lib` + - `tests/utils` + +- Run `moxunit_runtests tests` or `moxunit_runtests tests -verbose` to run the + tests. This should tell you which tests pass or fail. -## code coverage +## Adding more tests + +You can use the function template to write more tests. + +It is in the [`src/templates` folder](../src/templates) + +## Manual tests + +This is the folder where we keep tests that can not be run in continuous +integration even as simple "smoke tests". + + diff --git a/manualTests/test_makeRawDataset.m b/tests/manualTests/test_makeRawDataset.m similarity index 93% rename from manualTests/test_makeRawDataset.m rename to tests/manualTests/test_makeRawDataset.m index 7008843f..c9a0d39d 100644 --- a/manualTests/test_makeRawDataset.m +++ b/tests/manualTests/test_makeRawDataset.m @@ -213,13 +213,15 @@ function test_makeRawDataset() createJson(cfg, extraInfo); %% add dummy data + templateFolder = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'templates'); + subjectDir = fullfile(cfg.dir.output, 'source', 'sub-001', 'ses-001'); funcDir = fullfile(subjectDir, 'func'); boldFilename = 'sub-001_ses-001_task-testtask_run-001_bold.nii.gz'; copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(templateFolder, 'dummyData.nii.gz'), ... fullfile(funcDir, boldFilename)); boldFilename = ['sub-001_ses-001_task-rest', ... @@ -227,7 +229,7 @@ function test_makeRawDataset() '_run-001_echo-1_bold.nii.gz']; copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(templateFolder, 'dummyData.nii.gz'), ... fullfile(funcDir, boldFilename)); eegDir = fullfile(subjectDir, 'eeg'); @@ -241,19 +243,19 @@ function test_makeRawDataset() behFilename = 'sub-001_ses-001_task-easyTargetPractice_run-001_beh.tsv'; copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(templateFolder, 'dummyData.nii.gz'), ... fullfile(eegDir, eegFilename)); copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(templateFolder, 'dummyData.nii.gz'), ... fullfile(megDir, megFilename)); copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(templateFolder, 'dummyData.nii.gz'), ... fullfile(ieegDir, ieegFilename)); copyfile( ... - fullfile('dummyData', 'dummyData.nii.gz'), ... + fullfile(templateFolder, 'dummyData.nii.gz'), ... fullfile(behDir, behFilename)); %% actually do the conversion of the source data thus created diff --git a/tests/dummyData/sub-blind01_ses-01_task-vislocalizer_events.tsv b/tests/testData/sub-blind01_ses-01_task-vislocalizer_events.tsv similarity index 100% rename from tests/dummyData/sub-blind01_ses-01_task-vislocalizer_events.tsv rename to tests/testData/sub-blind01_ses-01_task-vislocalizer_events.tsv diff --git a/tests/test_readAndFilterLogfile.m b/tests/test_readAndFilterLogfile.m index cba936a7..b9f3275d 100644 --- a/tests/test_readAndFilterLogfile.m +++ b/tests/test_readAndFilterLogfile.m @@ -76,7 +76,7 @@ function test_readAndFilterLogfileFromFile() %% set up - inputFile = fullfile(fileparts(mfilename('fullpath')), 'dummyData', ... + inputFile = fullfile(fileparts(mfilename('fullpath')), 'testData', ... 'sub-blind01_ses-01_task-vislocalizer_events.tsv'); % filter file