diff --git a/MOcov/@MOcovMFileCollection/get_coverage_json.m b/MOcov/@MOcovMFileCollection/get_coverage_json.m index 6fe78b1..600ca58 100644 --- a/MOcov/@MOcovMFileCollection/get_coverage_json.m +++ b/MOcov/@MOcovMFileCollection/get_coverage_json.m @@ -27,14 +27,20 @@ obj.mfiles,... 'UniformOutput',false); source_files_json=strjoin(source_files_json_cell,','); + + misc_data=get_misc_data(params); + json=sprintf(['{ \n',... '"service_job_id": "%s",\n',... '"service_name": "%s",\n',... + '%s',... '"source_files": [\n%s\n]\n',... '}\n'],... service.job_id,... service.service_name,... - source_files_json); + misc_data,... + source_files_json... + ); @@ -50,9 +56,18 @@ if isequal(getenv('TRAVIS'),'true') params.service_name='travis-ci'; params.job_id=getenv('TRAVIS_JOB_ID'); - + params.parallel=getenv('TRAVIS_PARALLEL'); return; end params.job_id='job id unknown'; params.service_name='service name unknown'; + +function misc_data=get_misc_data(params) + misc_data_cell=cell(0); + if isfield(params,'parallel') + % attempt to support parallel + misc_data_cell{end+1}=sprintf(',"parallel": %s\n',... + lower(params.parallel)); + end + misc_data=sprintf('%s',misc_data_cell{:}); diff --git a/MOcov/mocov.m b/MOcov/mocov.m index 6155df4..87507e4 100644 --- a/MOcov/mocov.m +++ b/MOcov/mocov.m @@ -10,10 +10,12 @@ % - If a string, evaluate the expression expr % using 'eval' % - If a function handle, evaluate expr() -% Mutually exclusive with '-i' option. +% Mutually exclusive with '-profile_info' +% option. % '-profile_info' Use coverage based on profile('info'). Not % usable on the GNU Octave platform. -% Mutually exclusive with '-e' option. +% Mutually exclusive with '-expression' +% option. % '-cover', covd Find coverage for files in dir covd and all % of its subdirectories % '-cover_exclude', pat (optional) Exclude files and directories @@ -42,17 +44,17 @@ % % Examples: % % evaluate 'expr' while monitoring coverage of files in directory -% % 'dir_to_cover' by rewriting files in that directory to a +% % 'dir_to_cover' by rewriting files in that directory to a % % temporary directory; write coverage in HTML format in directory -% % 'html_output'. +% % 'html_output'. % mocov -cover dir_to_cover -cover_html_dir html_output -e expr % % % As above, but use Matlab profiler to monitor coverage % % (not usable on GNU Octave) % mocov -cover cover_dir -cover_html_dir output -e expr -v -m profile % -% -% +% +% % Notes: % - this function aims to be compatible with Matlab and GNU Octave. % - coverage reports for unit tests can be made together with MOxUnit. @@ -72,7 +74,7 @@ % get input arguments opt=parse_inputs(varargin{:}); - + % store original state of mocov_line_covered, and ensure it is reset % afterwards line_covered_state=mocov_line_covered(); @@ -81,19 +83,19 @@ % reset lines covered to empty mocov_line_covered([]); - + monitor=MOcovProgressMonitor(opt.verbose); mfile_collection=MOcovMFileCollection(opt.cover,... opt.method,... monitor,... opt.excludes); mfile_collection=prepare(mfile_collection); - cleaner_collection=onCleanup(@()cleanup(mfile_collection)); + cleaner_collection=onCleanup(@()cleanup(mfile_collection)); if ~isempty(opt.expression) % rewrite m-files (if method='file') and ensure that they are cleaned % up afterwards - + % evaluate expression, and assign output variables argout=evaluate_expression(opt.expression); n=numel(argout); @@ -205,7 +207,7 @@ function write_coverage_results(writers, mfile_collection, opt) case '-cover_method' k=k+1; opt.method=varargin{k}; - + case '-profile_info' opt.info_from_profile=true; @@ -226,7 +228,7 @@ function write_coverage_results(writers, mfile_collection, opt) opt.method='file'; end end - + check_inputs(opt); @@ -247,4 +249,3 @@ function check_inputs(opt) elseif opt.info_from_profile error('Options ''-e'' or ''i'' are mutually exclusive'); end - \ No newline at end of file