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