Skip to content

Commit 314d186

Browse files
ENH - updated test web interface, return more details from ft_version, check for local changes in ft_test_run
1 parent ea3c2b9 commit 314d186

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

utilities/ft_test_result.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@
5454
end
5555

5656
options = weboptions('ContentType','json'); % this returns the results as MATLAB structure
57-
results = webread('http://dashboard.fieldtriptoolbox.org/test', options);
58-
57+
results = webread('http://dashboard.fieldtriptoolbox.org/api', options);

utilities/ft_test_run.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
maxmem = str2mem(maxmem);
6666
end
6767

68-
[ftver, ftpath] = ft_version;
68+
% get the version and the path
69+
[revision, ftpath] = ft_version;
70+
71+
% testing a work-in-progress version is not supported
72+
assert(istrue(ft_version('clean')), 'this requires all local changes to be committed');
6973

7074
%% determine the list of functions to test
7175
if ~isempty(varargin) && exist(varargin{1}, 'file')
@@ -160,15 +164,16 @@
160164

161165
result = [];
162166
result.matlabversion = version('-release');
163-
result.fieldtripversion = ftver;
167+
result.fieldtripversion = revision;
168+
result.branch = ft_version('branch');
164169
result.hostname = gethostname;
165170
result.user = getusername;
166171
result.result = status;
167172
result.runtime = runtime;
168173
result.functionname = functionlist{i};
169174

170175
options = weboptions('MediaType','application/json');
171-
webwrite('http://dashboard.fieldtriptoolbox.org/test', result, options);
176+
webwrite('http://dashboard.fieldtriptoolbox.org/api', result, options);
172177
end
173178

174179
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

utilities/ft_version.m

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [ftver, ftpath] = ft_version
1+
function [ftver, ftpath] = ft_version(command)
22

33
% FT_VERSION returns the version and installation directory of FieldTrip
44
%
@@ -19,7 +19,7 @@
1919
%
2020
% See also VERSION, VER
2121

22-
% Copyright (C) 2012, Eelke Spaak
22+
% Copyright (C) 2012-2016, Eelke Spaak
2323
%
2424
% This file is part of FieldTrip, see http://www.ru.nl/donders/fieldtrip
2525
% for the documentation and details.
@@ -42,6 +42,11 @@
4242
persistent issvn
4343
persistent isgit
4444

45+
if nargin<1
46+
% this is only supported for git
47+
command='revision';
48+
end
49+
4550
ftpath = fileparts(mfilename('fullpath'));
4651
ftpath = ftpath(1:end-10); % strip away '/utilities' where this function is located
4752

@@ -81,20 +86,39 @@
8186
end
8287

8388
elseif isgit
84-
% use git system call to determine latest revision
85-
olddir = pwd();
86-
cd(ftpath);
87-
[status, output] = system(sprintf('git%s rev-parse --short HEAD', ext));
88-
cd(olddir);
89-
if status > 0
89+
% test whether the git executable is available
90+
[status, output] = system(sprintf('git%s --version', ext));
91+
if status>0
9092
if ~ispc
9193
% the command line tools will probably not be available on windows
92-
warning('you seem to have an GIT development copy of FieldTrip, yet ''git rev-parse'' does not work as expected');
94+
warning('you seem to have an GIT development copy of FieldTrip, yet ''git'' does not work as expected');
9395
end
9496
ftver = 'unknown';
97+
9598
else
96-
ftver = strtrim(output); % remove trailing newline character
97-
end
99+
% use git system call to determine latest revision
100+
olddir = pwd();
101+
cd(ftpath);
102+
switch command
103+
case 'branch'
104+
[status, output] = system(sprintf('git%s rev-parse --abbrev-ref HEAD', ext));
105+
ftver = strtrim(output); % remove trailing newline character
106+
case 'revision'
107+
[status, output] = system(sprintf('git%s rev-parse --short HEAD', ext));
108+
ftver = strtrim(output); % remove trailing newline character
109+
case 'clean'
110+
[status, output] = system(sprintf('git%s diff --quiet --exit-code', ext));
111+
if status
112+
ftver = 'no';
113+
else
114+
ftver = 'yes';
115+
end
116+
otherwise
117+
error('unsupported command "%s"');
118+
end
119+
cd(olddir);
120+
121+
end % if git available
98122

99123
elseif isequal(regexp(ftpath, ['.*' filesep 'fieldtrip-fieldtrip-[[0-9][a-z]]{7}']), 1)
100124
% this corresponds with being downloaded from the Mathworks file exchange link to github
@@ -114,6 +138,6 @@
114138
end % if issvn, isgit or otherwise
115139

116140
if nargout==0
117-
fprintf('\nThis is FieldTrip, version %s.\n\n', ftver);
118-
clear ftver
141+
fprintf('\nThis is FieldTrip, %s %s.\n\n', command, ftver);
142+
clear ftver ftpath
119143
end

0 commit comments

Comments
 (0)