Skip to content
Snippets Groups Projects
run_gdat_tests.m 2.06 KiB
Newer Older
function [passed,results] = run_gdat_tests(test_case)
% test runner for gdat

% F. Felici, EPFL federico.felici@epfl.ch

if nargin==0 || isempty(test_case)
  test_case = 'basic'; % default
% add path with tests
addpath(genpath(fullfile(fileparts(mfilename('fullpath')),'tests')));

suite_all = [matlab.unittest.TestSuite.fromClass(?test_requestnames_TCV),...
  matlab.unittest.TestSuite.fromClass(?test_requestnames_AUG)];

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.constraints.ContainsSubstring;
    
    suite = suite_all.selectIf(HasParameter('Value','TCV') & ...
      (HasParameter('Value','ip') | HasParameter('Value','q_rho')));
  case 'TCV'
    suite = suite_all.selectIf(HasParameter('machine',IsEqualTo('TCV')));
  case 'AUG'
    suite = suite_all.selectIf(HasParameter('machine',IsEqualTo('AUG')));
  otherwise
    error('not yet implemented')
end

%% run it
fprintf('Start test case: %s\n%s\n\n',test_case,datestr(now));
results = run(suite);
disp(table(results));
fprintf('\nTotal test duration: %5.2fs\n',sum(table(results).Duration))

%% display results
if all([results.Passed])
  fprintf('\nPassed all tests\n')
  passed = true;
else
  fprintf('\nSome tests Failed or Incomplete\n')
  if any([results.Incomplete])
    fprintf('\nIncomplete:\n')
    disp(table(results([results.Incomplete])))
  end
  if any([results.Failed])
    fprintf('\nFailed:\n')
    disp(table(results([results.Failed])));
  end
  passed = false;
end

end


function [shots,request_list] = get_gdat_test_params(machine)

% get requests for this machine
[gd0,~] = gdat('machine',machine);
request_list = gd0.gdat_request;

% get test shot list for this machine
shots = get_shots(machine);
end


function shots = get_shots(machine)
switch machine
  case 'AUG'
    shots = {num2str(30594)}; % use strings for display purposes
  case 'TCV'
    shots = {num2str(48836)};
  otherwise
    error('no shot defined for this machine')
end
end