|
1 | 1 | function test_suite = test_setTargetPositionInSequence %#ok<*STOUT> |
2 | 2 |
|
3 | | - if isOctave() |
4 | | - pkg('load','statistics'); |
5 | | - end |
| 3 | + initEnv() |
6 | 4 |
|
7 | 5 | try % assignment of 'localfunctions' is necessary in Matlab >= 2016 |
8 | 6 | test_functions = localfunctions(); %#ok<*NASGU> |
@@ -30,3 +28,50 @@ function test_setTargetPositionInSequenceBasic() |
30 | 28 | assertTrue(all(interval(:) > 1)); |
31 | 29 |
|
32 | 30 | end |
| 31 | + |
| 32 | +function initEnv |
| 33 | + |
| 34 | + octaveVersion = '4.0.3'; |
| 35 | + matlabVersion = '8.6.0'; |
| 36 | + |
| 37 | + installlist = {'statistics', 'image'}; |
| 38 | + |
| 39 | + if isOctave |
| 40 | + |
| 41 | + % Exit if min version is not satisfied |
| 42 | + if ~compare_versions(OCTAVE_VERSION, octaveVersion, '>=') |
| 43 | + error('Minimum required Octave version: %s', octaveVersion); |
| 44 | + end |
| 45 | + |
| 46 | + for ii = 1:length(installlist) |
| 47 | + try |
| 48 | + % Try loading Octave packages |
| 49 | + disp(['loading ' installlist{ii}]); |
| 50 | + pkg('load', installlist{ii}); |
| 51 | + |
| 52 | + catch |
| 53 | + errorcount = 1; |
| 54 | + while errorcount % Attempt twice in case installation fails |
| 55 | + try |
| 56 | + pkg('install', '-forge', installlist{ii}); |
| 57 | + pkg('load', installlist{ii}); |
| 58 | + errorcount = 0; |
| 59 | + catch err |
| 60 | + errorcount = errorcount + 1; |
| 61 | + if errorcount > 2 |
| 62 | + error(err.message); |
| 63 | + end |
| 64 | + end |
| 65 | + end |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | + else % MATLAB ---------------------------- |
| 70 | + |
| 71 | + if verLessThan('matlab', matlabVersion) |
| 72 | + error('Sorry, minimum required version is R2017b. :('); |
| 73 | + end |
| 74 | + |
| 75 | + end |
| 76 | + |
| 77 | +end |
0 commit comments