Mercurial > hg > camir-ismir2012
annotate core/tools/migrate_to_test_dir.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
rev | line source |
---|---|
Daniel@0 | 1 function out = migrate_to_test_dir(varargin) |
Daniel@0 | 2 % |
Daniel@0 | 3 % out = migrate_to_test_dir('testname', 'this is a test description') |
Daniel@0 | 4 % create test run directory, add current dir to path and move |
Daniel@0 | 5 % into test run dir |
Daniel@0 | 6 % |
Daniel@0 | 7 % NOTE: the test directory is created in "globalvars.testdatadir" if set |
Daniel@0 | 8 % |
Daniel@0 | 9 |
Daniel@0 | 10 global globalvars; |
Daniel@0 | 11 |
Daniel@0 | 12 [sTest,fixedtestdir, unused] = process_options(varargin, ... |
Daniel@0 | 13 'testname', '','fixedtestdir', ''); |
Daniel@0 | 14 |
Daniel@0 | 15 % use starting script name as description if none is given |
Daniel@0 | 16 if isempty(sTest) |
Daniel@0 | 17 [ST, I] = dbstack(); |
Daniel@0 | 18 sTest = ST(end).name; |
Daniel@0 | 19 end |
Daniel@0 | 20 |
Daniel@0 | 21 |
Daniel@0 | 22 % switch to test directory, and add this or current dir to path |
Daniel@0 | 23 if ~isempty(globalvars.tstoutputpath) && ~isempty(dir(globalvars.tstoutputpath)); |
Daniel@0 | 24 addpath(globalvars.tstoutputpath); |
Daniel@0 | 25 cd(globalvars.tstoutputpath); |
Daniel@0 | 26 else |
Daniel@0 | 27 addpath(pwd); |
Daniel@0 | 28 end |
Daniel@0 | 29 |
Daniel@0 | 30 % get camir version |
Daniel@0 | 31 [~,cv] = camirversion(); |
Daniel@0 | 32 |
Daniel@0 | 33 % get current date |
Daniel@0 | 34 sDate = datestr(now,'yymmdd'); |
Daniel@0 | 35 |
Daniel@0 | 36 if isempty(fixedtestdir) |
Daniel@0 | 37 newdir = sprintf('%s_%s_r%d',sDate,sTest,cv); |
Daniel@0 | 38 else |
Daniel@0 | 39 newdir = fixedtestdir; |
Daniel@0 | 40 end |
Daniel@0 | 41 |
Daniel@0 | 42 % create dir if not existent |
Daniel@0 | 43 if isempty(dir(newdir)); |
Daniel@0 | 44 mkdir(newdir); |
Daniel@0 | 45 end |
Daniel@0 | 46 |
Daniel@0 | 47 cd(newdir); |
Daniel@0 | 48 if ~isempty(strfind(pwd, newdir)) |
Daniel@0 | 49 out = newdir; |
Daniel@0 | 50 else |
Daniel@0 | 51 warning 'cannot migrate to specified test directory, Ill dump right here'; |
Daniel@0 | 52 out = -1; |
Daniel@0 | 53 end |