Skip to content

Commit

Permalink
Merge pull request #515 from Remi-Gau/misc-bug-squashing
Browse files Browse the repository at this point in the history
[FIX] Misc bug squashing 🐛 💀
  • Loading branch information
Remi-Gau authored Feb 6, 2022
2 parents c76e644 + 15e4b9b commit 418b16a
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests_matlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

cd(fullfile(root_dir));

initCppSpm(true);
cpp_spm('dev');

run run_tests();
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*_report.md

# General
.DS_Store

Expand All @@ -17,9 +18,9 @@ options_task-*date*.json
onsets*_events.mat

## virtual env
cpp_spm/*
env/*
venv/*
cpp_spm
env
venv

## visual studio code
.vscode
Expand Down
3 changes: 2 additions & 1 deletion manualTests/test_ds114.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
WD = fullfile(fileparts(mfilename('fullpath')), '..', 'demos', 'openneuro');
cd(WD);

run ../../initCppSpm.m;
addpath(fullfile(pwd, '..', '..'));
cpp_spm('init');

optionsFilesList = { ...
'options_task-linebisection.json'; ...
Expand Down
3 changes: 2 additions & 1 deletion manualTests/test_moae.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
WD = fullfile(fileparts(mfilename('fullpath')), '..', 'demos', 'MoAE');
cd(WD);

run ../../initCppSpm.m;
addpath(fullfile(pwd, '..', '..'));
cpp_spm('init');

%% Set up
optionsFilesList = {'options_task-auditory.json'; ...
Expand Down
2 changes: 1 addition & 1 deletion miss_hit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ regex_method_name: "[a-z]+([A-Z0-9]+[a-z]*)*"
# all uppercase or camelCase
regex_parameter_name: "[A-Z]+(_[A-Z]+)*|[a-z]+([A-Z]+[a-z]*)*"

suppress_rule: "naming_parameters"
# suppress_rule: "naming_parameters"

exclude_dir: "lib"

Expand Down
4 changes: 4 additions & 0 deletions src/IO/saveSpmScript.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
outputFilename = returnBatchFileName('', '.m');
end

% matlab scripts cannot have hyphens
filename = spm_file(outputFilename, 'filename');
outputFilename = spm_file(outputFilename, 'filename', strrep(filename, '-', '_'));

try
str = gencode(matlabbatch);
catch
Expand Down
3 changes: 2 additions & 1 deletion src/infra/getEnvInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
if bids.internal.starts_with(keyname, 'LS_COLORS')
% to prevent annoying warnign when field names are too long.
OS.environmentVariables.LS_COLORS = vals{i};
else
OS.environmentVariables.(keyname) = vals{i};
end
end
end
catch
errorHandling;
errorHandling(mfilename(), 'envUnknown', 'Could not get env info.', true, opt.verbosity);
end

Expand Down
11 changes: 7 additions & 4 deletions tests/tests_batches/test_saveMatlabBatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ function test_saveMatlabBatch_basic()
opt.dir.jobs = pwd;

matlabbatch = struct('test', 1);
saveMatlabBatch(matlabbatch, 'test', opt, subLabel);

expectedOutput = fullfile(pwd, ['sub-' subLabel], ...
['batch_test_' datestr(now, 'yyyy-mm-ddTHH-MM') '.mat']);

saveMatlabBatch(matlabbatch, 'test', opt, subLabel);

assertEqual(exist(expectedOutput, 'file'), 2);
assertEqual(exist(spm_file(expectedOutput, 'ext', '.m'), 'file'), 2);
assertEqual(exist(spm_file(expectedOutput, 'ext', '.json'), 'file'), 2);

expectedOutput = fullfile(pwd, ['sub-' subLabel], ...
['batch_test_' datestr(now, 'yyyy_mm_ddTHH_MM') '.m']);

assertEqual(exist(expectedOutput, 'file'), 2);

cleanUp(fullfile(pwd, ['sub-' subLabel]));

end
Expand All @@ -45,7 +48,7 @@ function test_saveMatlabBatch_group()
saveMatlabBatch(matlabbatch, 'groupTest', opt);

assertEqual(exist(expectedOutput, 'file'), 2);
assertEqual(exist(spm_file(expectedOutput, 'ext', '.m'), 'file'), 2);
assertEqual(exist(spm_file(strrep(expectedOutput, '-', '_'), 'ext', '.m'), 'file'), 2);

cleanUp(fullfile(pwd, 'group'));

Expand Down
22 changes: 22 additions & 0 deletions tests/tests_infra/test_getEnvInfo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
% (C) Copyright 2022 CPP_SPM developers

function test_suite = test_getEnvInfo %#ok<*STOUT>
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
test_functions = localfunctions(); %#ok<*NASGU>
catch % no problem; early Matlab versions can use initTestSuite fine
end
initTestSuite;
end

function test_getEnvInfo_basic()

opt.dryRun = false;
opt.versbosity = false;

[OS, generatedBy] = getEnvInfo(opt);

% OS.platform
% OS.environmentVariables
% generatedBy

end

0 comments on commit 418b16a

Please sign in to comment.