Skip to content

Commit

Permalink
Merge pull request #21 from LewisLabUCSD/CobraChange
Browse files Browse the repository at this point in the history
Update of functions in base
  • Loading branch information
laurentheirendt authored May 27, 2019
2 parents 137af58 + 1248546 commit e9e536b
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 10 deletions.
5 changes: 5 additions & 0 deletions test/base/clearGlobal.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ function clearGlobal(globalName)
%
% INPUTS:
% globalName: The name of the global variable to clear.
%
% NOTE:
% this function has been uploaded from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/utilities/clearGlobal.m
% [e6b4efd]

clearvars('-global',globalName);
end
6 changes: 6 additions & 0 deletions test/base/getEnvironment.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
% environment: a struct with two fields
% * .globals - contains all global values
% * .path - contains the current path
%
% NOTE:
% this function has been uploaded from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/utilities/getEnvironment.m
% [cadfa58]

environment = struct();
globals = struct();
globalvars = who('global');
Expand Down
6 changes: 6 additions & 0 deletions test/base/getFilesInDir.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
%
% % get only the gitIgnored files in the current folder
% files = getFilesInDir('type', 'ignored');
%
% NOTE:
% this function has been uploaded from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/install/getFilesInDir.m
% [cdb2478]


persistent COBRAIgnored

Expand Down
6 changes: 6 additions & 0 deletions test/base/getGlobalValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
%
% OUTPUT:
% value: The value of the requested global variable
%
% NOTE:
% this function has been uploaded from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/utilities/getGlobalValue.m
% [e6b4efd]


eval(['global ' globalName]);
eval(['value = ' globalName ';']);
Expand Down
8 changes: 7 additions & 1 deletion test/base/getIgnoredFiles.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
% ignoredFiles: All files (and patterns) indicated as ignored in
% the gitignore file.
%
% .. Authors: - Original Code: Laurent Heirandt
% .. Authors: - Original Code: Laurent Heirendt
% - Move to function: Thomas Pfau, Jan 2018
%
% NOTE:
% this function has been adapted from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/install/getIgnoredFiles.m
% [f9a9213]



global CELLFIEDIR
Expand Down
7 changes: 6 additions & 1 deletion test/base/restoreEnvironment.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ function restoreEnvironment(environment, restorePath, printLevel)
% printLevel: Set the verbosity of this method:
% * 0: No outputs (Default)
% * 1: Info what each value is set to
%
%
% NOTE:
% this function has been adapted from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/utilities/restoreEnvironment.m
% [005f7d1]

if ~exist('restorePath','var')
restorePath = true;
end
Expand Down
20 changes: 13 additions & 7 deletions test/base/runScriptFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,29 @@
% - `.Error`: Error message received from a failed or skipped test
%
% .. Author: - Thomas Pfau Jan 2018.
%
% NOTE:
% this function has been adapted from
% https://github.com/opencobra/cobratoolbox/blob/master/test/runScriptFile.m
% [b58da0c]


global CBT_MISSING_REQUIREMENTS_ERROR_ID

COBRA_TESTSUITE_TESTFILE = fileName;
CELLFIE_TESTSUITE_TESTFILE = fileName;

% get the timinig (and hope these values are not overwritten.
COBRA_TESTSUITE_STARTTIME = clock();
CELLFIE_TESTSUITE_STARTTIME = clock();

try
% run the file
executefile(fileName);
catch ME
% vatch errors and interpret them
clearvars -except ME COBRA_TESTSUITE_STARTTIME COBRA_TESTSUITE_TESTFILE CBT_MISSING_REQUIREMENTS_ERROR_ID
scriptTime = etime(clock(), COBRA_TESTSUITE_STARTTIME);
clearvars -except ME CELLFIE_TESTSUITE_STARTTIME CELLFIE_TESTSUITE_TESTFILE CBT_MISSING_REQUIREMENTS_ERROR_ID
scriptTime = etime(clock(), CELLFIE_TESTSUITE_STARTTIME);
result = struct('status', 'failed', 'failed', true, 'passed', false, 'skipped', false, 'fileName', ...
COBRA_TESTSUITE_TESTFILE, 'time', scriptTime, 'statusMessage', 'fail', 'Error', ME);
CELLFIE_TESTSUITE_TESTFILE, 'time', scriptTime, 'statusMessage', 'fail', 'Error', ME);
if strcmp(ME.identifier, CBT_MISSING_REQUIREMENTS_ERROR_ID)
% requirement missing, so the test was skipped.
result.status = 'skipped';
Expand All @@ -50,10 +56,10 @@
end

% get the timinig.
scriptTime = etime(clock(), COBRA_TESTSUITE_STARTTIME);
scriptTime = etime(clock(), CELLFIE_TESTSUITE_STARTTIME);

result = struct('status', 'passed', 'failed', false, 'passed', true, 'skipped', false, 'fileName', ...
COBRA_TESTSUITE_TESTFILE, 'time', scriptTime, 'statusMessage', 'success', 'Error', MException('', ''));
CELLFIE_TESTSUITE_TESTFILE, 'time', scriptTime, 'statusMessage', 'success', 'Error', MException('', ''));

end

Expand Down
6 changes: 6 additions & 0 deletions test/base/runTestSuite.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
%
% Author:
% - Thomas Pfau Jan 2018.
%
% NOTE:
% this function has been adapted from
% https://github.com/opencobra/cobratoolbox/blob/master/test/runTestSuite.m
% [5395578]


global CELLFIEDIR

Expand Down
8 changes: 7 additions & 1 deletion test/base/setGlobal.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ function setGlobal(globalName,globalValue)
%
% INPUTS:
% globalName: A string representing the name of the global variable
% globalValue: The value to set the global variable to
% globalValue: The value to set the global variable
%
% NOTE:
% this function has been adapted from
% https://github.com/opencobra/cobratoolbox/blob/master/src/base/utilities/setGlobal.m
% [e6b4efd]


eval([ globalName '_val = globalValue;']);
eval(['global ' globalName]);
Expand Down

0 comments on commit e9e536b

Please sign in to comment.