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