From 3ea6e956601d122eedd3f668ed9359ea3651a9eb Mon Sep 17 00:00:00 2001 From: "Adam L. Taylor" Date: Mon, 22 May 2023 16:46:16 -0400 Subject: [PATCH] Added test_all() --- test_all.m | 9 +++++ test_all_eight_major_configurations.m | 15 +++++++- test_all_verification_conditions.m | 29 +++++++++----- test_single_major_configuration.m | 1 + test_something.m | 54 --------------------------- test_verification_condition.m | 2 + 6 files changed, 45 insertions(+), 65 deletions(-) create mode 100644 test_all.m delete mode 100644 test_something.m diff --git a/test_all.m b/test_all.m new file mode 100644 index 0000000..82b3f56 --- /dev/null +++ b/test_all.m @@ -0,0 +1,9 @@ +function passed_count_and_run_count = test_all() + function_name_from_test_index = {'test_all_eight_major_configurations', 'test_all_verification_conditions' } ; + cell_results_from_test_index = cellfun(@feval, function_name_from_test_index, 'UniformOutput', false) ; + results_from_test_index = cell2mat(cell_results_from_test_index') ; % test_count x 2, 1st col subtests passed, 2nd col subtests run + passed_count_and_run_count = sum(results_from_test_index, 1) ; + passed_count = passed_count_and_run_count(1) ; + run_count = passed_count_and_run_count(2) ; + fprintf('Test summary: %d passed out of %d tests run.\n', passed_count, run_count) ; +end diff --git a/test_all_eight_major_configurations.m b/test_all_eight_major_configurations.m index 481c9c2..9c03c59 100644 --- a/test_all_eight_major_configurations.m +++ b/test_all_eight_major_configurations.m @@ -1,9 +1,20 @@ -function test_all_eight_major_configurations() +function pass_and_run_count = test_all_eight_major_configurations() + pass_count = 0 ; + run_count = 0 ; for freezing_or_thawing = { 'freezing', 'thawing' } , for raw_tiles_or_octree = { 'raw-tiles', 'octree' } , for local_or_cluster = { 'local', 'cluster' } , - test_single_major_configuration(freezing_or_thawing{1}, raw_tiles_or_octree{1}, local_or_cluster{1}) ; + run_count = run_count + 1 ; + try + test_single_major_configuration(freezing_or_thawing{1}, raw_tiles_or_octree{1}, local_or_cluster{1}) ; + pass_count = pass_count + 1 ; + catch me + report = me.getReport() ; + fprint('Caught error while running test_single_major_configuration(''%s'', ''%s'', ''%s'').\nException report:\n%s', ... + freezing_or_thawing{1}, raw_tiles_or_octree{1}, local_or_cluster{1}, report) ; + end end end end + pass_and_run_count = [pass_count run_count] ; end diff --git a/test_all_verification_conditions.m b/test_all_verification_conditions.m index f21f719..b468bf9 100644 --- a/test_all_verification_conditions.m +++ b/test_all_verification_conditions.m @@ -1,17 +1,28 @@ -function test_all_verification_conditions() - %for freezing_or_thawing = { 'freezing', 'thawing' } , - for freezing_or_thawing = { 'thawing' } , - %for raw_tiles_or_octree = { 'raw-tiles', 'octree' } , - for raw_tiles_or_octree = { 'octree' } , - %for local_or_cluster = { 'local', 'cluster' } , - for local_or_cluster = { 'local' } , +function pass_and_run_count = test_all_verification_conditions() + pass_count = 0 ; + run_count = 0 ; + for freezing_or_thawing = { 'freezing', 'thawing' } , + %for freezing_or_thawing = { 'thawing' } , + for raw_tiles_or_octree = { 'raw-tiles', 'octree' } , + %for raw_tiles_or_octree = { 'octree' } , + for local_or_cluster = { 'local', 'cluster' } , + %for local_or_cluster = { 'local' } , for stack_or_non_stack = { 'stack', 'non-stack' } , for exact_problem = { 'deleted', 'zero-length', 'corrupt' } , - test_verification_condition( ... - freezing_or_thawing{1}, raw_tiles_or_octree{1}, local_or_cluster{1}, stack_or_non_stack{1}, exact_problem{1}) ; + run_count = run_count + 1 ; + try + test_verification_condition( ... + freezing_or_thawing{1}, raw_tiles_or_octree{1}, local_or_cluster{1}, stack_or_non_stack{1}, exact_problem{1}) ; + pass_count = pass_count + 1 ; + catch me + report = me.getReport() ; + fprint('Caught error while running test_verification_condition(''%s'', ''%s'', ''%s'', ''%s'', ''%s'').\nException report:\n%s', ... + freezing_or_thawing{1}, raw_tiles_or_octree{1}, local_or_cluster{1}, stack_or_non_stack{1}, exact_problem{1}, report) ; + end end end end end end + pass_and_run_count = [pass_count run_count] ; end diff --git a/test_single_major_configuration.m b/test_single_major_configuration.m index 68291b2..265de8a 100644 --- a/test_single_major_configuration.m +++ b/test_single_major_configuration.m @@ -1,5 +1,6 @@ function test_single_major_configuration(freezing_or_thawing, raw_tiles_or_octree, local_or_cluster) % Test, in one of 2^3==8 possible configurations. + % This function returns normally if all is well, throws an error if not. % Deal with the arguments if ~strcmp(freezing_or_thawing, 'freezing') && ~strcmp(freezing_or_thawing, 'thawing') , diff --git a/test_something.m b/test_something.m deleted file mode 100644 index 2539f92..0000000 --- a/test_something.m +++ /dev/null @@ -1,54 +0,0 @@ -function test_something(freezing_or_thawing, raw_tiles_or_octree, local_or_cluster) - % Test, in one of 2^3==8 possible configurations. - - % Deal with the arguments - if ~strcmp(freezing_or_thawing, 'freezing') && ~strcmp(freezing_or_thawing, 'thawing') , - error('freezing_or_thawing must be ''freezing'' or ''thawing''') ; - end - if ~strcmp(raw_tiles_or_octree, 'raw-tiles') && ~strcmp(raw_tiles_or_octree, 'octree') , - error('raw_tiles_or_octree must be ''raw-tiles'' or ''octree''') ; - end - if ~strcmp(local_or_cluster, 'local') && ~strcmp(local_or_cluster, 'cluster') , - error('local_or_cluster must be ''local'' or ''cluster''') ; - end - - % Define all the needed inputs - path_to_this_folder = fileparts(mfilename('fullpath')) ; - output_folder_name = sprintf('%s-%s-test-output-folder', raw_tiles_or_octree, freezing_or_thawing) ; - output_folder_path = fullfile(path_to_this_folder, output_folder_name) ; - input_folder_name = sprintf('%s-%s-test-input-folder', raw_tiles_or_octree, freezing_or_thawing) ; - input_folder_path = fullfile(path_to_this_folder, input_folder_name) ; - compression_ratio = 10 ; % only used for freezing - do_run_on_cluster = strcmp(local_or_cluster, 'cluster') ; - do_try = false ; % if running locally, don't wrap in try so easier to debug - maximum_running_slot_count = 40 ; - submit_host_name = if_not_a_submit_host('login2.int.janelia.org') ; - - % Delete the test output folder - reset_for_test(output_folder_path) ; - - % Make sure the input folder exists - if ~logical(exist(input_folder_path, 'dir')) , - error('Input folder %s is missing, or is not a folder', input_folder_path) ; - end - - % Call the script - if strcmp(freezing_or_thawing, 'freezing') , - freeze_mouselight_folder(... - output_folder_path, ... - input_folder_path, ... - compression_ratio, ... - do_run_on_cluster, ... - do_try, ... - maximum_running_slot_count, ... - submit_host_name) ; - else - thaw_mouselight_folder(... - output_folder_path, ... - input_folder_path, ... - do_run_on_cluster, ... - do_try, ... - maximum_running_slot_count, ... - submit_host_name) ; - end -end diff --git a/test_verification_condition.m b/test_verification_condition.m index 2e0c7c5..5f3a70d 100644 --- a/test_verification_condition.m +++ b/test_verification_condition.m @@ -1,4 +1,6 @@ function test_verification_condition(freezing_or_thawing, raw_tiles_or_octree, local_or_cluster, stack_or_non_stack, exact_problem) + % This function returns normally if all is well, throws an error if not. + % Deal with the arguments if ~strcmp(freezing_or_thawing, 'freezing') && ~strcmp(freezing_or_thawing, 'thawing') , error('freezing_or_thawing must be ''freezing'' or ''thawing''') ;