wolffd@0: function out = migrate_to_test_dir(varargin) wolffd@0: % wolffd@0: % out = migrate_to_test_dir('testname', 'this is a test description') wolffd@0: % wolffd@0: % or wolffd@0: % wolffd@0: % out = migrate_to_test_dir('fixedtestdir', 'dirname') wolffd@0: % wolffd@0: % create test run directory, add current dir to path and move wolffd@0: % into test run dir wolffd@0: % wolffd@0: % NOTE: the test directory is created in "globalvars.testdatadir" if set wolffd@0: % wolffd@0: wolffd@0: global globalvars; wolffd@0: wolffd@0: [sTest,fixedtestdir, unused] = process_options(varargin, ... wolffd@0: 'testname', '','fixedtestdir', ''); wolffd@0: wolffd@0: % use starting script name as description if none is given wolffd@0: if isempty(sTest) wolffd@0: [ST, I] = dbstack(); wolffd@0: sTest = ST(end).name; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: % switch to test directory, and add this or current dir to path wolffd@0: if ~isempty(globalvars.tstoutputpath) && ~isempty(dir(globalvars.tstoutputpath)); wolffd@0: addpath(globalvars.tstoutputpath); wolffd@0: cd(globalvars.tstoutputpath); wolffd@0: else wolffd@0: addpath(pwd); wolffd@0: end wolffd@0: wolffd@0: % get camir version wolffd@0: [~,cv] = camirversion(); wolffd@0: wolffd@0: % get current date wolffd@0: sDate = datestr(now,'yymmdd'); wolffd@0: wolffd@0: if isempty(fixedtestdir) wolffd@0: newdir = sprintf('%s_%s_r%d',sDate,sTest,cv); wolffd@0: else wolffd@0: newdir = fixedtestdir; wolffd@0: end wolffd@0: wolffd@0: % create dir if not existent wolffd@0: if isempty(dir(newdir)); wolffd@0: mkdir(newdir); wolffd@0: end wolffd@0: wolffd@0: cd(newdir); wolffd@0: if ~isempty(strfind(pwd, newdir)) wolffd@0: out = newdir; wolffd@0: else wolffd@0: warning 'cannot migrate to specified test directory, Ill dump right here'; wolffd@0: out = -1; wolffd@0: end