Commit 268c6f06 authored by Federico Felici's avatar Federico Felici
Browse files

Rework test suite

* Add 'Slow' tag to mark slow tests
* Separation slow/fast tests done in logical place: get_all_gdat_requests.m
* Added 'TCV' and 'AUG' test options
parent a8c1ec07
Pipeline #13355 failed with stage
in 1 minute and 11 seconds
......@@ -7,6 +7,11 @@ if nargin==0 || isempty(test_case)
test_case = 'basic'; % default
end
%% Import some classes we need
import matlab.unittest.selectors.HasTag;
import matlab.unittest.constraints.ContainsSubstring;
import matlab.unittest.selectors.HasName;
%% populate suite
% add path with tests
addpath(genpath(fullfile(fileparts(mfilename('fullpath')),'tests')));
......@@ -20,17 +25,19 @@ switch test_case
case 'all'
suite = suite_all; % run all
case 'basic'
import matlab.unittest.selectors.HasParameter;
import matlab.unittest.selectors.HasName;
import matlab.unittest.selectors.HasTag;
import matlab.unittest.constraints.ContainsSubstring;
s1 = HasName(ContainsSubstring('TCV')) & ...
(HasParameter('Value','ip') | HasParameter('Value','q_rho'));
suite = suite_all.selectIf(s1);
s = ~HasTag('Slow');
suite = suite_all.selectIf(s);
case 'IMAS'
s2 = HasTag('IMAS');
suite = suite_all.selectIf(s2);
s = HasTag('IMAS');
suite = suite_all.selectIf(s);
case 'TCV'
s = HasName(ContainsSubstring('TCV'));
suite = suite_all.selectIf(s);
case 'AUG'
s = HasName(ContainsSubstring('AUG'));
suite = suite_all.selectIf(s);
otherwise
error('not yet implemented')
end
......
function requests = get_all_gdat_requests(machine)
function requests = get_all_gdat_requests(machine,testcase)
[gd0,~] = gdat('machine',machine);
requests = gd0.gdat_request;
switch machine
% list of calls that take some time, to be skipped for fast tests
case 'TCV'
slowlist = {'rtc','mhd','mpx','sxr','psi'};
case 'AUG'
slowlist = {'sxr','cxrs','transp','te_rho','ne_rho','nete_rho',...
'ece_rho','eced_rho','cxrs_rho','eqdsk','equil'};
end
switch testcase
case 'fast'
requests = requests(~ismember(requests,slowlist));
% choose tests not on the slowlist
case 'slow'
requests = requests(ismember(requests,slowlist));
% choose only tests on the slowlist
otherwise
error('unknown test_case %s',testcase);
end
end
\ No newline at end of file
......@@ -4,36 +4,45 @@ classdef (SharedTestFixtures={...
properties (Abstract)
Machine;
Skiplist; % tests to skip
end
properties(TestParameter,Abstract)
% parameters that will vary during tests
shot;
request; % placeholders
requests_fast; % placeholders
requests_slow;
end
methods(Test)
function test_gdat_call(testCase,shot,request)
testCase.assertTrue(isnumeric(str2double(shot)));
testCase.assertTrue(ischar(request));
testCase.assumeFalse(ismember(testCase.Skiplist,request),...
sprintf('Skipped request %s since it is on the skiplist for %s',request,testCase.Machine));
% gdat call
gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request);
% logging
fprintf('Testing gdat call: %s\n',gdat_call);
gdat_out = eval(gdat_call); %#ok<NASGU>
% in some future: check for warnings
%gdat_out = verifyWarningFree(testCase,eval(gdat_call),...
% 'Warning issued from gdat call:\n %s\n',gdat_call);
% (add optional sanity checks of gdat_out here)
methods(Test,TestTags = {'Fast'})
function test_gdat_call_fast(testCase,shot,requests_fast)
test_gdat_call(testCase,shot,requests_fast);
end
end
methods(Test,TestTags = {'Slow'})
function test_gdat_call_slow(testCase,shot,requests_slow)
test_gdat_call(testCase,shot,requests_slow);
end
end
end
function test_gdat_call(testCase,shot,request)
% actual function to test gdat call
testCase.assertTrue(isnumeric(str2double(shot)));
testCase.assertTrue(ischar(request));
% gdat call
gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request);
% logging
fprintf('Testing gdat call: %s\n',gdat_call);
gdat_out = eval(gdat_call); %#ok<NASGU>
% in some future: check for warnings
%gdat_out = verifyWarningFree(testCase,eval(gdat_call),...
% 'Warning issued from gdat call:\n %s\n',gdat_call);
% (add optional sanity checks of gdat_out here)
end
\ No newline at end of file
......@@ -3,14 +3,13 @@ classdef test_requestnames_AUG < test_requestnames
properties
Machine = 'AUG';
Skiplist = {'cxrs','transp','te_rho','ne_rho','nete_rho','ece_rho','eced_rho','cxrs_rho','eqdsk','equil'};
% skip these equest names
end
properties(TestParameter)
% parameters that will vary during tests
shot = {'30594'};
request = get_all_gdat_requests('AUG');
requests_fast = get_all_gdat_requests('AUG','fast');
requests_slow = get_all_gdat_requests('AUG','slow');
end
end
\ No newline at end of file
......@@ -3,13 +3,13 @@ classdef test_requestnames_TCV < test_requestnames
properties
Machine = 'TCV';
Skiplist = {''}; % skip these calls
end
properties(TestParameter)
% parameters that will vary during tests
shot = {'48836'};
request = get_all_gdat_requests('TCV');
requests_fast = get_all_gdat_requests('TCV','fast');
requests_slow = get_all_gdat_requests('TCV','slow');
end
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment