Mercurial > hg > camir-aes2014
diff core/tools/migrate_to_test_dir.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/tools/migrate_to_test_dir.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,58 @@ +function out = migrate_to_test_dir(varargin) +% +% out = migrate_to_test_dir('testname', 'this is a test description') +% +% or +% +% out = migrate_to_test_dir('fixedtestdir', 'dirname') +% +% create test run directory, add current dir to path and move +% into test run dir +% +% NOTE: the test directory is created in "globalvars.testdatadir" if set +% + +global globalvars; + +[sTest,fixedtestdir, unused] = process_options(varargin, ... + 'testname', '','fixedtestdir', ''); + +% use starting script name as description if none is given +if isempty(sTest) + [ST, I] = dbstack(); + sTest = ST(end).name; +end + + +% switch to test directory, and add this or current dir to path +if ~isempty(globalvars.tstoutputpath) && ~isempty(dir(globalvars.tstoutputpath)); + addpath(globalvars.tstoutputpath); + cd(globalvars.tstoutputpath); +else + addpath(pwd); +end + +% get camir version +[~,cv] = camirversion(); + +% get current date +sDate = datestr(now,'yymmdd'); + +if isempty(fixedtestdir) + newdir = sprintf('%s_%s_r%d',sDate,sTest,cv); +else + newdir = fixedtestdir; +end + +% create dir if not existent +if isempty(dir(newdir)); + mkdir(newdir); +end + +cd(newdir); +if ~isempty(strfind(pwd, newdir)) + out = newdir; +else + warning 'cannot migrate to specified test directory, Ill dump right here'; + out = -1; +end \ No newline at end of file