From c824bf7689ebc22961fb6f543b9edd996e6ba7ba Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Wed, 16 Jan 2019 18:34:04 +0000
Subject: [PATCH] add function call and indent

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@11304 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/test_all_requestnames.m | 131 +++++++++++++++-----------------
 1 file changed, 63 insertions(+), 68 deletions(-)

diff --git a/crpptbx/test_all_requestnames.m b/crpptbx/test_all_requestnames.m
index cb36376d..dc2c8565 100644
--- a/crpptbx/test_all_requestnames.m
+++ b/crpptbx/test_all_requestnames.m
@@ -1,4 +1,7 @@
 function [pass,request_list,err,telaps,skipped] = test_all_requestnames(varargin)
+%
+% [pass,request_list,err,telaps,skipped] = test_all_requestnames(varargin);
+%
 % test function to run all requestnames
 %  pass = test_gdat_AUG; % default test
 %  pass = test_gdat_AUG('param1',value1,'param2',value2,...); %
@@ -18,34 +21,34 @@ function [pass,request_list,err,telaps,skipped] = test_all_requestnames(varargin
 
 %
 if nverbose>=2
-    doplot = true;
+  doplot = true;
 else
-    doplot = false;
+  doplot = false;
 end
 
 %% get request list
 [gd0,gp0] = gdat;
 if isempty(machine)
-    machine = gp0.machine;
+  machine = gp0.machine;
 end
 request_list = gd0.gdat_request;
 
 %% get default test shot for each machine
 switch upper(machine)
-    case 'AUG'
-        shot = 30594;
-    case 'TCV'
-        shot = 48836;
+ case 'AUG'
+  shot = 30594;
+ case 'TCV'
+  shot = 48836;
 end
 
 %% possibly skip some since they take too long for a reduced test
 switch testmode
-    case 'reduced'
-        skip = skip_list(machine);
-    case 'full'
-        skip = ''; % skip none
-    otherwise
-        error('invalid testmode, should be ''reduced'' or ''full''');
+ case 'reduced'
+  skip = skip_list(machine);
+ case 'full'
+  skip = ''; % skip none
+ otherwise
+  error('invalid testmode, should be ''reduced'' or ''full''');
 end
 
 %% init
@@ -57,38 +60,36 @@ gdat_call = cell(Nreq,1);
 
 %% call gdat requests in a loop
 for ireq = 1:Nreq
-    myrequest = request_list{ireq};
+  myrequest = request_list{ireq};
+  
+  if ~ismember(myrequest,skip)
+    % build request string
+    gdat_call{ireq} = sprintf('gdat_aug(%d,''%s'',''doplot'',%d,''machine'',''%s'')',shot,myrequest,doplot,machine);
     
-    if ~ismember(myrequest,skip)
-        % build request string
-        gdat_call{ireq} = sprintf('gdat_aug(%d,''%s'',''doplot'',%d,''machine'',''%s'')',shot,myrequest,doplot,machine);
-        
-        % eval call
-        [err(ireq),telaps(ireq)] = do_gdat_call(gdat_call{ireq},nverbose);
-        skipped(ireq) = false;
-        pause(0.1)
-    else
-        % skip
-        err(ireq) = 0;
-        telaps(ireq) = 0;
-        skipped(ireq) = true;
-        fprintf('\n skipping gdat request ''%s''\n',myrequest)
-    end
+    % eval call
+    [err(ireq),telaps(ireq)] = do_gdat_call(gdat_call{ireq},nverbose);
+    skipped(ireq) = false;
+    pause(0.1)
+  else
+    % skip
+    err(ireq) = 0;
+    telaps(ireq) = 0;
+    skipped(ireq) = true;
+    fprintf('\n skipping gdat request ''%s''\n',myrequest)
+  end
 end
 
 pass = all(~err);
 
 %% Summary display
 if nverbose
-    summary_display(request_list,telaps,err,gdat_call,skipped)
-
-    if pass
-        fprintf('passed %s tests\n',mfilename());
-    else
-        fprintf('test FAILED: %s.m\n',mfilename());
-    end
-end
+  summary_display(request_list,telaps,err,gdat_call,skipped)
 
+  if pass
+    fprintf('passed %s tests\n',mfilename());
+  else
+    fprintf('test FAILED: %s.m\n',mfilename());
+  end
 end
 
 function [machine,testmode,verbose] = parse_inputs(varargin)
@@ -101,78 +102,72 @@ p.parse(varargin{:});
 machine  = p.Results.machine;
 testmode = p.Results.testmode;
 verbose  = p.Results.nverbose;
-end
 
 function skip = skip_list(machine)
 switch upper(machine)
-    case 'AUG'
-        skip = {'cxrs','transp','te_rho','ne_rho','nete_rho','ece_rho','eced_rho','cxrs_rho','eqdsk','equil'};
-    otherwise
-        warning('no list to skip defined for machine ''%s''',machine);
-        skip = '';
-end
+ case 'AUG'
+  skip = {'cxrs','transp','te_rho','ne_rho','nete_rho','ece_rho','eced_rho','cxrs_rho','eqdsk','equil'};
+ otherwise
+  warning('no list to skip defined for machine ''%s''',machine);
+  skip = '';
 end
 
 function [err,telaps] = do_gdat_call(gdat_call,nverbose)
 if nverbose
-    fprintf('\n calling %s...\n',gdat_call);
+  fprintf('\n calling %s...\n',gdat_call);
 end
 
 tic
 try
-    [~,~,err] = eval(gdat_call);
+  [~,~,err] = eval(gdat_call);
 catch ME
-    warning('Caught matlab error. Report:\n\n%s',getReport(ME,'extended'));
-    err = -1;
+  warning('Caught matlab error. Report:\n\n%s',getReport(ME,'extended'));
+  err = -1;
 end
 telaps = toc; % elapsed time
-end
 
 function summary_display(request_list,telaps,err,gdat_call,skipped)
 %%
 Nreq = numel(request_list);
 
 if any(err==0)
-fprintf('\n\n  PASSED:\n')
-print_header();
-for ireq=1:Nreq
+  fprintf('\n\n  PASSED:\n')
+  print_header();
+  for ireq=1:Nreq
     if ~skipped(ireq) && ~err(ireq)
-        print_result(request_list{ireq},telaps(ireq),err(ireq),gdat_call{ireq})
+      print_result(request_list{ireq},telaps(ireq),err(ireq),gdat_call{ireq})
     end
-end
+  end
 end
 
 if any(skipped) 
-fprintf('\n\n  SKIPPED:\n')
-print_header();
-for ireq=1:Nreq
+  fprintf('\n\n  SKIPPED:\n')
+  print_header();
+  for ireq=1:Nreq
     if skipped(ireq)
-        fprintf('   %-20s%-20s\n',request_list{ireq},'skipped');
+      fprintf('   %-20s%-20s\n',request_list{ireq},'skipped');
     end
-end
+  end
 end
 
 if any(err~=0)
-fprintf('\n\n  FAILED:\n')
-print_header();
-for ireq=1:Nreq
+  fprintf('\n\n  FAILED:\n')
+  print_header();
+  for ireq=1:Nreq
     if ~skipped(ireq) && (err(ireq)~=0)
-        print_result(request_list{ireq},telaps(ireq),err(ireq),gdat_call{ireq})
+      print_result(request_list{ireq},telaps(ireq),err(ireq),gdat_call{ireq})
     end
-end
+  end
 end
 
 fprintf('\n\n   total test time: %2.2f[s]\n\n',sum(telaps));
 
-end
 
 function print_header()
 fprintf('   %-60s\n',char(repmat(int8('-'),1,60)))
 fprintf('   %-20s%-20s%-10s%-100s\n','request','time_elapsed[''s'']','errorcode','gdat call')
 fprintf('   %-60s\n',char(repmat(int8('-'),1,60)))
-end
+
 
 function print_result(req,telaps,err,callstr)
 fprintf('   %-20s%-20.2f%-10d%-100s\n',req,telaps,err,callstr);
-end
-
-- 
GitLab