annotate 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
rev   line source
wolffd@0 1 function out = migrate_to_test_dir(varargin)
wolffd@0 2 %
wolffd@0 3 % out = migrate_to_test_dir('testname', 'this is a test description')
wolffd@0 4 %
wolffd@0 5 % or
wolffd@0 6 %
wolffd@0 7 % out = migrate_to_test_dir('fixedtestdir', 'dirname')
wolffd@0 8 %
wolffd@0 9 % create test run directory, add current dir to path and move
wolffd@0 10 % into test run dir
wolffd@0 11 %
wolffd@0 12 % NOTE: the test directory is created in "globalvars.testdatadir" if set
wolffd@0 13 %
wolffd@0 14
wolffd@0 15 global globalvars;
wolffd@0 16
wolffd@0 17 [sTest,fixedtestdir, unused] = process_options(varargin, ...
wolffd@0 18 'testname', '','fixedtestdir', '');
wolffd@0 19
wolffd@0 20 % use starting script name as description if none is given
wolffd@0 21 if isempty(sTest)
wolffd@0 22 [ST, I] = dbstack();
wolffd@0 23 sTest = ST(end).name;
wolffd@0 24 end
wolffd@0 25
wolffd@0 26
wolffd@0 27 % switch to test directory, and add this or current dir to path
wolffd@0 28 if ~isempty(globalvars.tstoutputpath) && ~isempty(dir(globalvars.tstoutputpath));
wolffd@0 29 addpath(globalvars.tstoutputpath);
wolffd@0 30 cd(globalvars.tstoutputpath);
wolffd@0 31 else
wolffd@0 32 addpath(pwd);
wolffd@0 33 end
wolffd@0 34
wolffd@0 35 % get camir version
wolffd@0 36 [~,cv] = camirversion();
wolffd@0 37
wolffd@0 38 % get current date
wolffd@0 39 sDate = datestr(now,'yymmdd');
wolffd@0 40
wolffd@0 41 if isempty(fixedtestdir)
wolffd@0 42 newdir = sprintf('%s_%s_r%d',sDate,sTest,cv);
wolffd@0 43 else
wolffd@0 44 newdir = fixedtestdir;
wolffd@0 45 end
wolffd@0 46
wolffd@0 47 % create dir if not existent
wolffd@0 48 if isempty(dir(newdir));
wolffd@0 49 mkdir(newdir);
wolffd@0 50 end
wolffd@0 51
wolffd@0 52 cd(newdir);
wolffd@0 53 if ~isempty(strfind(pwd, newdir))
wolffd@0 54 out = newdir;
wolffd@0 55 else
wolffd@0 56 warning 'cannot migrate to specified test directory, Ill dump right here';
wolffd@0 57 out = -1;
wolffd@0 58 end