Skip to content

Commit

Permalink
Merge pull request #73 from MarcinKonowalczyk/skip-slow-octave
Browse files Browse the repository at this point in the history
TST+CMPT: Skip slow tests in octave on windows
  • Loading branch information
nno committed Oct 23, 2020
2 parents 093fdfd + fdf8ca9 commit 9388565
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
44 changes: 35 additions & 9 deletions tests/test_moxunit_runtests.m
Expand Up @@ -6,14 +6,20 @@
initTestSuite;

function test_moxunit_runtests_basics
slow_flag = ispc() && moxunit_util_platform_is_octave();
if slow_flag
% Skip if running in octave on windows. From some reason Octave
% chokes heavilly on temporary file access and deletion.
reason = '''test_moxunit_runtests_basics'' is very slow in Octave on Windows!';
moxunit_throw_test_skipped_exception(reason)
fprintf('This test will take a very long time\n');
end
passed_cell={'','abs(2);','for k=1:10,2+k;end'};
failed_cell={'error(''expected'');','[1,2]+[1,2,3];'};
skipped_cell={'moxunit_throw_test_skipped_exception(''skip'')'};

combis=all_binary_combinations(8);
for k=1:size(combis,1)
cleaner=onCleanup(@()cleanup_helper('cleanup'));

log_fn=tempname();
cleanup_helper('add_file',log_fn);

Expand Down Expand Up @@ -86,8 +92,10 @@
test_stats,test_labels)

end

cleaner=[];
cleanup_helper('cleanup');
if slow_flag
fprintf('Combination test #%d/%d\n',k,size(combis,1))
end
end

function test_moxunit_runtests_partitions
Expand Down Expand Up @@ -257,13 +265,31 @@ function mkdir_recursively(dir_name)
case 'cleanup'
assert(numel(varargin)==0);
if iscell(files)
for k=1:numel(files)
file=files{k};
if exist(file,'file');
delete(file);

if moxunit_util_platform_is_octave()
for k=1:numel(files)
file = files{k};
if exist(file,'file')
%tic
unlink(file); % This is a bit faster in Octave
%toc
end
end

else
s = warning('error','MATLAB:DELETE:Permission'); %#ok<CTPCT>
c = onCleanup(@() warning(s)); % Reset warning state

for k=1:numel(files)
file = files{k};
if exist(file,'file')
try %#ok<TRYNC>
delete(file);
end
end
end
end

files=[];
end

Expand Down
19 changes: 18 additions & 1 deletion tests/test_moxunit_util_mfile_subfunctions.m
Expand Up @@ -92,6 +92,16 @@ function test_multiple_tilde_newline_subfunction()
function test_different_args_subfunction
% test with various types of whitespace, number of input arguments, and
% number of output arguments

slow_flag = ispc() && moxunit_util_platform_is_octave();
if slow_flag
% Skip if running in octave on windows. From some reason Octave
% chokes heavilly on temporary file access and deletion.
reason = '''test_different_args_subfunction'' is very slow in Octave on Windows!';
moxunit_throw_test_skipped_exception(reason)
fprintf('This test will take a very long time\n');
end

whitespace_cell={' ',...
' ',...
sprintf('\t'),...
Expand All @@ -107,6 +117,9 @@ function test_multiple_tilde_newline_subfunction()
parts={'function',arg_out,func_name,arg_in};
line=moxunit_util_strjoin(parts,whitespace);
helper_test_with_lines({func_name},max(n_out,0),{line});
if slow_flag
fprintf('i_sp: %0f, n_out: %0f, n_in: %0f\n',i_sp,n_out,n_in)
end
end
end
end
Expand Down Expand Up @@ -136,7 +149,11 @@ function helper_test_with_lines(func_names, n_out, lines)
assert(iscell(lines));

tmp_fn=tempname();
file_deleter=onCleanup(@()delete(tmp_fn));
if moxunit_util_platform_is_octave
cleaner=onCleanup(@()unlink(tmp_fn)); % Faster in Octave
else
cleaner=onCleanup(@()delete(tmp_fn));
end

% try different line endings
line_ending_cell={'\r\n',... % MS Windows
Expand Down

0 comments on commit 9388565

Please sign in to comment.