From 472e5f40bed37e92f124d84e77c58fd5e63375d6 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 13 Jan 2021 09:02:49 +0100 Subject: [PATCH 1/5] move manual test folder --- {manualTests => tests/manualTests}/dummyData/.bidsignore | 0 {manualTests => tests/manualTests}/dummyData/CHANGES | 0 {manualTests => tests/manualTests}/dummyData/README | 0 {manualTests => tests/manualTests}/dummyData/dummyData.nii.gz | 0 {manualTests => tests/manualTests}/miss_hit.cfg | 0 {manualTests => tests/manualTests}/test_makeRawDataset.m | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {manualTests => tests/manualTests}/dummyData/.bidsignore (100%) rename {manualTests => tests/manualTests}/dummyData/CHANGES (100%) rename {manualTests => tests/manualTests}/dummyData/README (100%) rename {manualTests => tests/manualTests}/dummyData/dummyData.nii.gz (100%) rename {manualTests => tests/manualTests}/miss_hit.cfg (100%) rename {manualTests => tests/manualTests}/test_makeRawDataset.m (100%) diff --git a/manualTests/dummyData/.bidsignore b/tests/manualTests/dummyData/.bidsignore similarity index 100% rename from manualTests/dummyData/.bidsignore rename to tests/manualTests/dummyData/.bidsignore diff --git a/manualTests/dummyData/CHANGES b/tests/manualTests/dummyData/CHANGES similarity index 100% rename from manualTests/dummyData/CHANGES rename to tests/manualTests/dummyData/CHANGES diff --git a/manualTests/dummyData/README b/tests/manualTests/dummyData/README similarity index 100% rename from manualTests/dummyData/README rename to tests/manualTests/dummyData/README diff --git a/manualTests/dummyData/dummyData.nii.gz b/tests/manualTests/dummyData/dummyData.nii.gz similarity index 100% rename from manualTests/dummyData/dummyData.nii.gz rename to tests/manualTests/dummyData/dummyData.nii.gz diff --git a/manualTests/miss_hit.cfg b/tests/manualTests/miss_hit.cfg similarity index 100% rename from manualTests/miss_hit.cfg rename to tests/manualTests/miss_hit.cfg diff --git a/manualTests/test_makeRawDataset.m b/tests/manualTests/test_makeRawDataset.m similarity index 100% rename from manualTests/test_makeRawDataset.m rename to tests/manualTests/test_makeRawDataset.m From cf8d57198fc156a7e5204757ccbafe5eea49d365 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 13 Jan 2021 09:15:16 +0100 Subject: [PATCH 2/5] centralize test data --- .../sub-blind01_ses-01_task-vislocalizer_events.tsv | 0 tests/test_readAndFilterLogfile.m | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/{dummyData => testData}/sub-blind01_ses-01_task-vislocalizer_events.tsv (100%) 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 From bc2e0c90699aeebb80a19c67047a30f79e177e09 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 13 Jan 2021 09:15:57 +0100 Subject: [PATCH 3/5] move template data and files out of test folder --- src/convertSourceToRaw.m | 20 ++++++++----------- .../dummyData => templates}/.bidsignore | 0 .../dummyData => templates}/CHANGES | 0 .../dummyData => templates}/README | 0 .../dummyData => templates}/dummyData.nii.gz | 0 tests/manualTests/test_makeRawDataset.m | 14 +++++++------ 6 files changed, 16 insertions(+), 18 deletions(-) rename {tests/manualTests/dummyData => templates}/.bidsignore (100%) rename {tests/manualTests/dummyData => templates}/CHANGES (100%) rename {tests/manualTests/dummyData => templates}/README (100%) rename {tests/manualTests/dummyData => templates}/dummyData.nii.gz (100%) diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index edb6dcaf..1a4aab4c 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -23,18 +23,14 @@ function convertSourceToRaw(cfg) rawDir = fullfile(cfg.dir.output, 'raw'); % add dummy README and CHANGE file - copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... - 'README'), ... - sourceDir); - copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... - 'CHANGES'), ... - sourceDir); - copyfile(fullfile( ... - fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', ... - '.bidsignore'), ... - sourceDir); + templateFolder = fullfile(fileparts(mfilename('fullpath')), '..', 'templates'); + + copyfile(fullfile(templateFolder, 'README'), ... + sourceDir); + copyfile(fullfile(templateFolder, 'CHANGES'), ... + sourceDir); + copyfile(fullfile(templateFolder, '.bidsignore'), ... + sourceDir); copyfile(sourceDir, rawDir); diff --git a/tests/manualTests/dummyData/.bidsignore b/templates/.bidsignore similarity index 100% rename from tests/manualTests/dummyData/.bidsignore rename to templates/.bidsignore diff --git a/tests/manualTests/dummyData/CHANGES b/templates/CHANGES similarity index 100% rename from tests/manualTests/dummyData/CHANGES rename to templates/CHANGES diff --git a/tests/manualTests/dummyData/README b/templates/README similarity index 100% rename from tests/manualTests/dummyData/README rename to templates/README diff --git a/tests/manualTests/dummyData/dummyData.nii.gz b/templates/dummyData.nii.gz similarity index 100% rename from tests/manualTests/dummyData/dummyData.nii.gz rename to templates/dummyData.nii.gz diff --git a/tests/manualTests/test_makeRawDataset.m b/tests/manualTests/test_makeRawDataset.m index 7008843f..14104a77 100644 --- a/tests/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 From 29cf15dc30e1ac6bf38dbadd32e57fc652c64bb7 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 13 Jan 2021 09:16:22 +0100 Subject: [PATCH 4/5] update doc and CI --- .travis.yml | 2 +- src/templates/test_templateTest.m | 4 +- tests/README.md | 77 +++++++++---------------------- tests/manualTests/miss_hit.cfg | 9 ---- 4 files changed, 27 insertions(+), 65 deletions(-) delete mode 100644 tests/manualTests/miss_hit.cfg 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/src/templates/test_templateTest.m b/src/templates/test_templateTest.m index 73b91769..ef847186 100644 --- a/src/templates/test_templateTest.m +++ b/src/templates/test_templateTest.m @@ -23,7 +23,9 @@ function test_templateTestBasic() % expectedOuput = X; % assertEqual(actualOupout, expectedOuput) - + % assertTrue( ); + % assertFalse( ); + %% clean up (delete temporary files that were created) end diff --git a/tests/README.md b/tests/README.md index 9d8452e4..61e3c361 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,23 +6,38 @@ - 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) + + diff --git a/tests/manualTests/miss_hit.cfg b/tests/manualTests/miss_hit.cfg deleted file mode 100644 index d86aaeb0..00000000 --- a/tests/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 From 143d3cf8074347aaaeaf2a39510fdc7e01b407f9 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 13 Jan 2021 09:37:08 +0100 Subject: [PATCH 5/5] update doc and fix linting --- src/convertSourceToRaw.m | 8 ++++---- src/templates/test_templateTest.m | 2 +- tests/README.md | 5 +++++ tests/manualTests/test_makeRawDataset.m | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index 1a4aab4c..6a35504c 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -24,13 +24,13 @@ function convertSourceToRaw(cfg) % add dummy README and CHANGE file templateFolder = fullfile(fileparts(mfilename('fullpath')), '..', 'templates'); - + copyfile(fullfile(templateFolder, 'README'), ... - sourceDir); + sourceDir); copyfile(fullfile(templateFolder, 'CHANGES'), ... - sourceDir); + sourceDir); copyfile(fullfile(templateFolder, '.bidsignore'), ... - sourceDir); + sourceDir); copyfile(sourceDir, rawDir); diff --git a/src/templates/test_templateTest.m b/src/templates/test_templateTest.m index ef847186..b293a352 100644 --- a/src/templates/test_templateTest.m +++ b/src/templates/test_templateTest.m @@ -25,7 +25,7 @@ function test_templateTestBasic() % assertEqual(actualOupout, expectedOuput) % assertTrue( ); % assertFalse( ); - + %% clean up (delete temporary files that were created) end diff --git a/tests/README.md b/tests/README.md index 61e3c361..c4ee1b18 100644 --- a/tests/README.md +++ b/tests/README.md @@ -24,6 +24,11 @@ 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". +