Skip to content

Commit 1e956bb

Browse files
committed
improve tests for remove date suffix
1 parent beb0466 commit 1e956bb

File tree

7 files changed

+38
-44
lines changed

7 files changed

+38
-44
lines changed

.gitignore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
*octave-workspace
77

88
# exclude content of logfiles folders
9-
tests/output/*
10-
manualTests/output/*
11-
output/*
9+
*output*
1210
*.tsv
1311
*.mat
1412

1513
# exclude temp files from tests and coverage
16-
tests/coverage*
17-
tests/test_code_report.txt
18-
test_code_report.txt
19-
*/coverage_html/*
14+
*test_code_report.txt
15+
*coverage*
16+
17+
tests/*.nii*
18+
tests/*.json*
19+
tests/*.tsv*
2020

2121
# exclude report from check_my_code
2222
check_my_code_report.txt
File renamed without changes.
File renamed without changes.
File renamed without changes.

manualTests/test_makeRawDataset.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function test_makeRawDataset()
8686
boldFilename = 'sub-001_ses-001_task-testtask_run-001_bold.nii.gz';
8787

8888
copyfile( ...
89-
fullfile('..', 'dummyData', 'dummyData.nii.gz'), ...
89+
fullfile('dummyData', 'dummyData.nii.gz'), ...
9090
fullfile(funcDir, boldFilename));
9191

9292
%% MRI bold rest data and fancy suffixes
@@ -121,7 +121,7 @@ function test_makeRawDataset()
121121
'_run-004_echo-1_bold.nii.gz'];
122122

123123
copyfile( ...
124-
fullfile('..', 'dummyData', 'dummyData.nii.gz'), ...
124+
fullfile('dummyData', 'dummyData.nii.gz'), ...
125125
fullfile(funcDir, boldFilename));
126126

127127
%% actually do the conversion of the source data thus created

src/convertSourceToRaw.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ function convertSourceToRaw(cfg)
1414

1515
% add dummy README and CHANGE file
1616
copyfile(fullfile( ...
17-
fileparts(mfilename('fullpath')), '..', 'dummyData', 'README'), ...
17+
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'README'), ...
1818
sourceDir);
1919
copyfile(fullfile( ...
20-
fileparts(mfilename('fullpath')), '..', 'dummyData', 'CHANGES'), ...
20+
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'CHANGES'), ...
2121
sourceDir);
2222

2323
copyfile(sourceDir, rawDir);

tests/test_removeDateSuffix.m

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,12 @@
77
end
88

99
function test_removeDateSuffixBasic()
10-
11-
%% set up
12-
cfg.dir.output = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
13-
14-
% clean up
15-
if isdir(cfg.dir.output)
16-
rmdir(cfg.dir.output, 's');
17-
end
18-
[~, ~, ~] = mkdir(cfg.dir.output);
19-
20-
% TODO
21-
% make sure we use the default date parameter (to implement?)
22-
% cfg = checkCFG(cfg);
23-
10+
11+
outputDir = pwd;
12+
13+
createFiles = 0;
14+
testDo = 1;
15+
2416
%% set up
2517
boldName = 'test_bold_date-202008050730.nii.gz';
2618
boldName2 = 'test2_bold.nii.gz';
@@ -29,7 +21,7 @@ function test_removeDateSuffixBasic()
2921
eventsName = 'test_events_date-202008050730.tsv';
3022
stimName = 'test_stim_date-202008050730.tsv';
3123
stimNameZipped = 'test2_stim_date-202008050730.tsv.gz';
32-
24+
3325
filesToProcess = { ...
3426
boldName ;
3527
boldName2 ;
@@ -39,18 +31,16 @@ function test_removeDateSuffixBasic()
3931
stimName ;
4032
stimNameZipped ;
4133
};
42-
34+
35+
% create new files for new tests
4336
for iFile = 1:numel(filesToProcess)
44-
copyfile( ...
45-
fullfile('..', 'dummyData', 'dummyData.nii.gz'), ...
46-
fullfile(cfg.dir.output, filesToProcess{iFile}));
37+
system(sprintf('touch %s', filesToProcess{iFile}));
4738
end
48-
39+
40+
4941
%% do stuff
50-
filenames = file_utils('List', cfg.dir.output, '^test.*$');
51-
52-
removeDateSuffix(filenames, cfg.dir.output);
53-
42+
filenames = file_utils('List', outputDir, '^test.*$');
43+
5444
%% expected data
5545
expectedBoldName = 'test_bold.nii.gz';
5646
expectedBoldName2 = 'test2_bold.nii.gz';
@@ -59,14 +49,18 @@ function test_removeDateSuffixBasic()
5949
expectedEventsName = 'test_events.tsv';
6050
expectedStimName = 'test_stim.tsv';
6151
expectedStimNameZipped = 'test2_stim.tsv.gz';
62-
52+
53+
removeDateSuffix(filenames, outputDir);
54+
6355
%% test
64-
assertEqual(exist(fullfile(cfg.dir.output, expectedBoldName3), 'file'), 2);
65-
assertEqual(exist(fullfile(cfg.dir.output, expectedJsonName), 'file'), 2);
66-
assertEqual(exist(fullfile(cfg.dir.output, expectedEventsName), 'file'), 2);
67-
assertEqual(exist(fullfile(cfg.dir.output, expectedStimName), 'file'), 2);
68-
assertEqual(exist(fullfile(cfg.dir.output, expectedStimNameZipped), 'file'), 2);
69-
assertEqual(exist(fullfile(cfg.dir.output, expectedBoldName2), 'file'), 2);
70-
assertEqual(exist(fullfile(cfg.dir.output, expectedBoldName), 'file'), 2);
71-
56+
fprintf(1, fullfile(outputDir, expectedBoldName3));
57+
assertEqual(exist(fullfile(outputDir, expectedBoldName3), 'file'), 2);
58+
assertEqual(exist(fullfile(outputDir, expectedJsonName), 'file'), 2);
59+
fprintf(1, fullfile(outputDir, expectedEventsName));
60+
assertEqual(exist(fullfile(outputDir, expectedEventsName), 'file'), 2);
61+
assertEqual(exist(fullfile(outputDir, expectedStimName), 'file'), 2);
62+
assertEqual(exist(fullfile(outputDir, expectedStimNameZipped), 'file'), 2);
63+
assertEqual(exist(fullfile(outputDir, expectedBoldName2), 'file'), 2);
64+
assertEqual(exist(fullfile(outputDir, expectedBoldName), 'file'), 2);
65+
7266
end

0 commit comments

Comments
 (0)