From b1258bd83ea19bf7f0fa22ac93050a72035dfb8c Mon Sep 17 00:00:00 2001 From: Federico Felici <federico.felici@epfl.ch> Date: Tue, 5 Oct 2021 09:19:38 +0200 Subject: [PATCH] Add requestnames testing function as method --- matlab/tests/test_requestnames.m | 70 ++++++++++++++-------------- matlab/tests/test_requestnames_aug.m | 4 +- matlab/tests/test_requestnames_tcv.m | 4 +- 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/matlab/tests/test_requestnames.m b/matlab/tests/test_requestnames.m index 01527a07..63595919 100644 --- a/matlab/tests/test_requestnames.m +++ b/matlab/tests/test_requestnames.m @@ -1,46 +1,48 @@ classdef (SharedTestFixtures={... check_mds,check_gdatpaths}) ... test_requestnames < matlab.unittest.TestCase - + properties (Abstract) Machine; end - + properties(TestParameter,Abstract) % parameters that will vary during tests shot; requests_fast; % placeholders requests_slow; end -end - -function test_gdat_call(testCase,shot,request) %#ok<DEFNU> -% 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); -do_gdat_call = 1; - -switch request - case 'eqdsk' - % avoid writing files in /tmp, may not be allowed - gdat_call = sprintf(['gdat_%s(%s,''%s'',''write'',0)'],lower(testCase.Machine),shot,request); - end - -% logging -fprintf('Testing gdat call: %s\n',gdat_call); - -if do_gdat_call - gdat_out = eval(gdat_call); %#ok<NASGU> -else - gdat_out = struct([]); -end - -% 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 + + methods(Static) + 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); + do_gdat_call = 1; + + switch request + case 'eqdsk' + % avoid writing files in /tmp, may not be allowed + gdat_call = sprintf(['gdat_%s(%s,''%s'',''write'',0)'],lower(testCase.Machine),shot,request); + end + + % logging + fprintf('Testing gdat call: %s\n',gdat_call); + + if do_gdat_call + gdat_out = eval(gdat_call); %#ok<NASGU> + else + gdat_out = struct([]); + end + + % 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 + end +end \ No newline at end of file diff --git a/matlab/tests/test_requestnames_aug.m b/matlab/tests/test_requestnames_aug.m index 7521b34b..d05879f2 100644 --- a/matlab/tests/test_requestnames_aug.m +++ b/matlab/tests/test_requestnames_aug.m @@ -14,13 +14,13 @@ classdef (TestTags={'aug'})test_requestnames_aug < test_requestnames methods(Test,TestTags = {'fast'}) function test_gdat_call_fast(testCase,shot,requests_fast) - test_gdat_call(testCase,shot,requests_fast); + testCase.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); + testCase.test_gdat_call(testCase,shot,requests_slow); end end end \ No newline at end of file diff --git a/matlab/tests/test_requestnames_tcv.m b/matlab/tests/test_requestnames_tcv.m index e625ba60..f40ecbfa 100644 --- a/matlab/tests/test_requestnames_tcv.m +++ b/matlab/tests/test_requestnames_tcv.m @@ -14,13 +14,13 @@ classdef (TestTags={'tcv'})test_requestnames_tcv < test_requestnames methods(Test,TestTags = {'fast'}) function test_gdat_call_fast(testCase,shot,requests_fast) - test_gdat_call(testCase,shot,requests_fast); + testCase.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); + testCase.test_gdat_call(testCase,shot,requests_slow); end end -- GitLab