0001 function dsUnitSaveAutoGenTestDir(argin, argout, dirIn, dirOut, localFn_flag)
0002
0003
0004
0005
0006
0007
0008 if ~exist('localFn_flag','var')
0009 localFn_flag = false;
0010 end
0011
0012
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
0025 testDirName = sprintf('%s_autogen_%s', fnName, hash);
0026 testFileDir = fullfile(dsGetConfig('ds_unitTestData_path'), 'autogenDirs_newSave', testDirName);
0027 mkdirSilent(testFileDir);
0028
0029
0030 testFileName = 'args.mat';
0031 testFilePath = fullfile(testFileDir, testFileName);
0032 save(testFilePath, 'argin', 'argout')
0033
0034
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)
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
0052
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
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