Skip to content

Commit

Permalink
do not validate during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Sep 11, 2024
1 parent 9ad5b01 commit ca95c60
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
10 changes: 0 additions & 10 deletions tests/tests_utils/test_create_participants_tsv.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ function test_create_participants_tsv_basic()
bids_path = fullfile(bids_path, 'asl001');
end

validate_dataset(bids_path);

output_filename = bids.util.create_participants_tsv(bids_path, 'verbose', false);

participants = bids.util.tsvread(output_filename);
assertEqual(participants.participant_id, {'sub-Sub103'});

validate_dataset(bids_path);

delete(output_filename);

end
Expand All @@ -34,20 +30,14 @@ function test_create_participants_tsv_already_exist()
skip_if_octave('mixed-string-concat warning thrown');

bids_path = temp_dir();

copyfile(fullfile(get_test_data_dir(), 'ds210'), bids_path);

if bids.internal.is_octave
bids_path = fullfile(bids_path, 'ds210');
end

output_filename = bids.util.create_participants_tsv(bids_path);

validate_dataset(bids_path);

assertWarning(@()bids.util.create_participants_tsv(bids_path, 'verbose', true), ...
'create_participants_tsv:participantFileExist');

delete(output_filename);

end
15 changes: 8 additions & 7 deletions tests/tests_utils/test_create_readme.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@

function test_create_readme_basic()

bids_path = fullfile(get_test_data_dir(), 'ds210');

validate_dataset(bids_path);
source_ds = fullfile(get_test_data_dir(), 'ds210');
tmp_path = temp_dir();
copyfile(source_ds, tmp_path);
if bids.internal.is_octave()
bids_path = fullfile(tmp_path, 'ds210');
else
bids_path = tmp_path;
end

bids.util.create_readme(bids_path, false, ...
'tolerant', true, ...
'verbose', false);

assertEqual(exist(fullfile(bids_path, 'README.md'), 'file'), 2);

validate_dataset(bids_path);

delete(fullfile(bids_path, 'README.md'));

end

function test_create_readme_warning_already_present()
Expand Down
8 changes: 0 additions & 8 deletions tests/tests_utils/test_create_scans_tsv.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ function test_create_scans_tsv_basic_no_session()
bids_path = tmp_path;
end

validate_dataset(bids_path);

output_filenames = bids.util.create_scans_tsv(bids_path, 'verbose', false);

assertEqual(numel(output_filenames), 1);
assertEqual(exist(fullfile(bids_path, output_filenames{1}), 'file'), 2);
content = bids.util.tsvread(fullfile(bids_path, output_filenames{1}));
assertEqual(fieldnames(content), {'filename'; 'acq_time'; 'comments'});

validate_dataset(bids_path);

end

function test_create_scans_tsv_basic()
Expand All @@ -41,15 +37,11 @@ function test_create_scans_tsv_basic()
bids_path = tmp_path;
end

validate_dataset(bids_path);

output_filenames = bids.util.create_scans_tsv(bids_path, 'verbose', false);

assertEqual(numel(output_filenames), 28);
assertEqual(exist(fullfile(bids_path, output_filenames{1}), 'file'), 2);
content = bids.util.tsvread(fullfile(bids_path, output_filenames{1}));
assertEqual(fieldnames(content), {'filename'; 'acq_time'; 'comments'});

validate_dataset(bids_path);

end
12 changes: 4 additions & 8 deletions tests/tests_utils/test_create_sessions_tsv.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ function test_create_sessions_tsv_no_session()
bids_path = fullfile(bids_path, 'ds210');
end

validate_dataset(bids_path);

output_filenames = bids.util.create_sessions_tsv(bids_path, 'verbose', false);

assert(isempty(output_filenames));

validate_dataset(bids_path);

skip_if_octave('mixed-string-concat warning thrown');

assertWarning(@() bids.util.create_sessions_tsv(bids_path, 'verbose', true), ...
Expand All @@ -35,21 +31,21 @@ function test_create_sessions_tsv_basic()

bids_path = temp_dir();

copyfile(fullfile(get_test_data_dir(), 'ieeg_epilepsy'), bids_path);
copyfile(fullfile(get_test_data_dir(), 'synthetic'), bids_path);

if bids.internal.is_octave
bids_path = fullfile(bids_path, 'ieeg_epilepsy');
bids_path = fullfile(bids_path, 'synthetic');
end

validate_dataset(bids_path);

output_filenames = bids.util.create_sessions_tsv(bids_path, 'verbose', false);

assertEqual(numel(output_filenames), 1);
assertEqual(numel(output_filenames), 5);
assertEqual(exist(fullfile(bids_path, output_filenames{1}), 'file'), 2);
content = bids.util.tsvread(fullfile(bids_path, output_filenames{1}));
assertEqual(fieldnames(content), {'session_id'; 'acq_time'; 'comments'});
assertEqual(content.session_id, {'ses-postimp'; 'ses-preimp'});
assertEqual(content.session_id, {'ses-01'; 'ses-02'});

validate_dataset(bids_path);

Expand Down
6 changes: 1 addition & 5 deletions tests/utils/validate_dataset.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
function validate_dataset(bids_path)

if ispc
return
end

[sts, msg] = bids.validate(bids_path, '--config.ignore=99 --ignoreNiftiHeaders');
[sts, msg] = bids.validate(bids_path, '--ignoreNiftiHeaders');
assert(sts == 0, msg);

end

0 comments on commit ca95c60

Please sign in to comment.