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