Skip to content

Commit 9d9bd8b

Browse files
committed
add run tests to API
1 parent 478ab19 commit 9d9bd8b

File tree

3 files changed

+55
-35
lines changed

3 files changed

+55
-35
lines changed

cpp_spm.m

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ function cpp_spm(varargin)
4949

5050
uninitCppSpm();
5151

52+
case 'run_tests'
53+
54+
run_tests();
55+
5256
end
5357

5458
end
@@ -247,3 +251,47 @@ function uninitCppSpm()
247251
end
248252

249253
end
254+
255+
function run_tests()
256+
%
257+
% (C) Copyright 2019 CPP_SPM developers
258+
259+
% Elapsed time is 284 seconds.
260+
261+
tic;
262+
263+
cpp_spm('init');
264+
265+
if isGithubCi
266+
fprintf(1, '\nThis is github CI\n');
267+
else
268+
fprintf(1, '\nThis is not github CI\n');
269+
end
270+
271+
fprintf('\nHome is %s\n', getenv('HOME'));
272+
273+
warning('OFF');
274+
275+
spm('defaults', 'fMRI');
276+
277+
folderToCover = fullfile(pwd, 'src');
278+
testFolder = fullfile(pwd, 'tests');
279+
280+
success = moxunit_runtests( ...
281+
testFolder, ...
282+
'-verbose', '-recursive', '-with_coverage', ...
283+
'-cover', folderToCover, ...
284+
'-cover_xml_file', 'coverage.xml', ...
285+
'-cover_html_dir', fullfile(pwd, 'coverage_html'));
286+
287+
if success
288+
system('echo 0 > test_report.log');
289+
else
290+
system('echo 1 > test_report.log');
291+
end
292+
293+
cpp_spm('uninit');
294+
295+
toc;
296+
297+
end

initCppSpm.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ function initCppSpm(dev)
1111

1212
warning('DEPRECATED: use `cpp_spm(''init'')` instead');
1313

14+
if nargin < 1
15+
dev = false;
16+
end
17+
1418
if dev
15-
cpp_spm('dec');
19+
cpp_spm('dev');
1620
else
1721
cpp_spm('init');
1822
end

run_tests.m

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,5 @@
11
% (C) Copyright 2019 CPP_SPM developers
22

3-
% Elapsed time is 284 seconds.
3+
warning('DEPRECATED: use `cpp_spm(''run_tests'')` instead');
44

5-
tic;
6-
7-
initCppSpm(true);
8-
9-
if isGithubCi
10-
fprintf(1, '\nThis is github CI\n');
11-
else
12-
fprintf(1, '\nThis is not github CI\n');
13-
end
14-
15-
fprintf('\nHome is %s\n', getenv('HOME'));
16-
17-
warning('OFF');
18-
19-
spm('defaults', 'fMRI');
20-
21-
folderToCover = fullfile(pwd, 'src');
22-
testFolder = fullfile(pwd, 'tests');
23-
24-
success = moxunit_runtests( ...
25-
testFolder, ...
26-
'-verbose', '-recursive', '-with_coverage', ...
27-
'-cover', folderToCover, ...
28-
'-cover_xml_file', 'coverage.xml', ...
29-
'-cover_html_dir', fullfile(pwd, 'coverage_html'));
30-
31-
if success
32-
system('echo 0 > test_report.log');
33-
else
34-
system('echo 1 > test_report.log');
35-
end
36-
37-
toc;
5+
cpp_spm('run_tests');

0 commit comments

Comments
 (0)