Home > functions > internal > unit-test > dsUnitSaveAutoGenTestDir.m

dsUnitSaveAutoGenTestDir

PURPOSE ^

Inputs:

SYNOPSIS ^

function dsUnitSaveAutoGenTestDir(argin, argout, dirIn, dirOut, localFn_flag)

DESCRIPTION ^

 Inputs:
   argin: cell array with input arguments
   argout: cell array with output arguments
   dirin: path to directory that is input to fxn
   localFn_flag: logical of whether to include 'fn1__fn2' in fnName or 'fn1'

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dsUnitSaveAutoGenTestDir(argin, argout, dirIn, dirOut, localFn_flag)
0002 % Inputs:
0003 %   argin: cell array with input arguments
0004 %   argout: cell array with output arguments
0005 %   dirin: path to directory that is input to fxn
0006 %   localFn_flag: logical of whether to include 'fn1__fn2' in fnName or 'fn1'
0007 
0008 if ~exist('localFn_flag','var')
0009   localFn_flag = false;
0010 end
0011 
0012 % get fn name from stack
0013 stack = dbstack;
0014 if ~localFn_flag
0015   fnNameStack = stack(2).name;
0016   fnName = fnNameStack;
0017 else
0018   fnNameStack = stack(4).name;
0019   fnName = [fnNameStack '__' stack(3).name];
0020 end
0021 
0022 hash = DataHash(argin);
0023 
0024 % test dir
0025 testDirName = sprintf('%s_autogen_%s', fnName, hash);
0026 testFileDir = fullfile(dsGetConfig('ds_unitTestData_path'), 'autogenDirs_newSave', testDirName);
0027 mkdirSilent(testFileDir);
0028 
0029 % args file
0030 testFileName = 'args.mat';
0031 testFilePath = fullfile(testFileDir, testFileName);
0032 save(testFilePath, 'argin', 'argout')
0033 
0034 % output dir
0035 if exist('dirOut', 'var') && ~isempty(dirOut)
0036   testOutputDir = fullfile(testFileDir, 'output');
0037   mkdirSilent(testOutputDir);
0038   
0039   studyDirInd = find(strcmp(argin, 'study_dir'));
0040   if ~isempty(studyDirInd) % if study_dir defined in argin
0041     studyDir = argin{studyDirInd+1};
0042     testOutputStudyDir = fullfile(testOutputDir,studyDir);
0043     mkdirSilent(testOutputStudyDir);
0044     
0045     copyfile(dirOut, testOutputStudyDir);
0046   else
0047     copyfile(dirOut, testOutputDir);
0048   end
0049 end
0050 
0051 % argout fig handles to output dir
0052 %     TODO: generalize fig handle checking
0053 if all(isValidFigHandle(argout{1}))
0054   handles = argout{1};
0055   testOutputDir = fullfile(testFileDir, 'output');
0056   mkdirSilent(testOutputDir);
0057   
0058   dsUnitSave_figHandles( handles, testOutputDir )
0059 end
0060 
0061 % input dir
0062 if exist('dirIn', 'var') && ~isempty(dirIn)
0063   testInputDir = fullfile(testFileDir, 'input');
0064   mkdirSilent(testInputDir);
0065   
0066   copyfile(dirIn, testInputDir);
0067 end
0068 
0069 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005