Home > functions > internal > unit-test > dsUnitRun_autogen_all_jenkins.m

dsUnitRun_autogen_all_jenkins

PURPOSE ^

% Run all autogen tests

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% Run all autogen tests
 result_localfn = runtests('dsUnitTest_autogen_all_localfn');
 result = runtests('dsUnitTest_autogen_all');

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Run all autogen tests
0002 % result_localfn = runtests('dsUnitTest_autogen_all_localfn');
0003 % result = runtests('dsUnitTest_autogen_all');
0004 
0005 import matlab.unittest.TestSuite
0006 import matlab.unittest.TestRunner
0007 import matlab.unittest.selectors.HasTag
0008 import matlab.unittest.plugins.CodeCoveragePlugin
0009 import edu.stanford.covert.test.Coverage
0010 
0011 %% workspace
0012 fprintf('Running from dir:%s\n',pwd);
0013 [~,ws] = system('echo $WORKSPACE');
0014 ws = strtrim(ws);
0015 fprintf('Workspace:%s\n',ws);
0016 
0017 %% fix paths
0018 fprintf('Fixing paths.\n');
0019 rmPathVar('ds');
0020 addpath(genpath(ws));
0021 
0022 %% Make Default Config
0023 dsMakeDefaultConfigJenkins;
0024 
0025 %% Rename autogen_newSave to autogen
0026 finalDir = fullfile(dsGetConfig('ds_unitTestData_path'), 'autogen');
0027 if ~exist(finalDir, 'dir')
0028   newDir = fullfile(dsGetConfig('ds_unitTestData_path'), 'autogen_newSave');
0029   movefile(newDir, finalDir);
0030 end
0031 
0032 %% Rename autogenDirs_newSave to autogenDirs
0033 finalDir = fullfile(dsGetConfig('ds_unitTestData_path'), 'autogenDirs');
0034 newDir = fullfile(dsGetConfig('ds_unitTestData_path'), 'autogenDirs_newSave');
0035 if ~exist(finalDir, 'dir') && exist(newDir, 'dir')
0036   movefile(newDir, finalDir);
0037 end
0038 
0039 %% Make Test Suite
0040 fullSuite = TestSuite.fromPackage('dsUnit');
0041 fullSuite = fullSuite.selectIf(~HasTag('query'));
0042 fullSuite = fullSuite.selectIf(HasTag('autogen'));
0043 
0044 %% code coverage runner
0045 % runner = TestRunner.withTextOutput;
0046 % runner.addPlugin(CodeCoveragePlugin.forFolder(fullfile(ds_root_path, 'functions')))
0047 % runner.addPlugin(CodeCoveragePlugin.forPackage('ds'))
0048 
0049 %% Run Test Suite
0050 % results = run(fullSuite); % test suite without code covereage or parallel
0051 % results = runner.run(fullSuite); % runner for code coverage
0052 
0053 %% Run Test Suite in Parallel
0054 runner = matlab.unittest.TestRunner.withTextOutput;
0055 try
0056   results = runInParallel(runner,fullSuite); % runner in parallel, no code coverage
0057   display(results);
0058 
0059   %% XML Coverage Output
0060   testCoverageDir = fullfile(ws, 'testCoverage');
0061   mkdirSilent(testCoverageDir);
0062   reportPath = fullfile(testCoverageDir, 'dsAllAutogenTestCoverageJenkins.xml');
0063   report = Coverage( fullfile(ws, 'functions'), ws );
0064   report.exportXML(reportPath);
0065 
0066   %% get coverage percentage
0067   coverPercent = report.stats.lineRate;
0068   if isnan(coverPercent)
0069     coverPercent = 0;
0070   end
0071   coverPercentStr = sprintf('%.f', coverPercent);
0072   fprintf('Test Coverage (%% of code lines): %s\n', coverPercentStr);
0073 
0074   %% make coverage svg
0075   filepath = dsGetConfig('ds_jenkins_badge_path');
0076   system(['python ' dsGetConfig('ds_universal_coverage_badge_py_path') ' ' coverPercentStr ' -o ' filePath ' -f True']);
0077 catch e
0078   disp(getReport(e,'extended'))
0079   exit(1);
0080 end
0081 
0082 exit(any([results.Failed]));

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005