From aafe35107da028350d62b12bb002dacb44bd2676 Mon Sep 17 00:00:00 2001 From: JulioV Date: Thu, 8 Apr 2021 16:14:10 -0400 Subject: [PATCH] Fix missing pid files directory --- tests/scripts/run_tests.py | 9 +++++---- tests/scripts/run_tests.sh | 28 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/scripts/run_tests.py b/tests/scripts/run_tests.py index 8e0fa90a..3ea8086d 100644 --- a/tests/scripts/run_tests.py +++ b/tests/scripts/run_tests.py @@ -37,7 +37,8 @@ class RapidsTests(unittest.TestCase): # Loop through the file_list dictionary and check if the files exist. file_lists = self.generate_sensor_file_lists() for each in file_lists: - print("The actual output file should exist: {}".format(each[0])) + print("Checking if the output file exists: {}".format(each[0])) + print(os.path.exists( each[0])) self.assertEqual(os.path.exists( each[0]), 1) @@ -48,12 +49,12 @@ class RapidsTests(unittest.TestCase): df_exp = pd.read_csv(exp_result) if df_act.empty: print(act_result) - print("The expected output should be empty: {}".format(exp_result)) + print("Checking if the output file is empty: {}".format(exp_result)) self.assertTrue(df_exp.empty) else: # The order in which the columns varies from time to time so # the columns are sorted before doing the comparision - print("Comparing: {} and {}".format(act_result, exp_result)) + print("Comparing {} and {}".format(act_result, exp_result)) df_exp = df_exp.reindex(sorted(df_exp.columns), axis=1) df_act = df_act.reindex(sorted(df_act.columns), axis=1) pd.testing.assert_frame_equal(df_exp, df_act, obj=df_exp) @@ -94,7 +95,7 @@ def run_some_tests(test_type): elif test_type == "event": test_class = TestEvent else: - raise ValueError("Only frequency or periodic are valid arguments") + raise ValueError("Only frequency, periodic, and event are valid arguments") loader = unittest.TestLoader() suite = loader.loadTestsFromTestCase(test_class) diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index c2e5a906..07a9924c 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -1,10 +1,10 @@ #!/bin/bash run_pipeline() { - if [ $TYPE == 'frequency' ] + if [ "$TYPE" == 'frequency' ] then CONFIG_FILE="./tests/settings/frequency_config.yaml" - elif [ $TYPE == 'event' ] + elif [ "$TYPE" == 'event' ] then CONFIG_FILE="./tests/settings/event_config.yaml" else @@ -12,6 +12,7 @@ run_pipeline() { fi echo "Copying participant files" + mkdir -p data/external/participant_files/ cp -r tests/data/external/participant_files/* data/external/participant_files/ echo $TYPE @@ -23,7 +24,7 @@ run_pipeline() { } display_usage() { - echo "Usage: run_test.sh [-t|--type] [periodic | frequency] [-a|--action] [ all | run | test]" + echo "Usage: run_test.sh [-t|--type] [periodic | frequency | event] [-a|--action] [ all | run | both]" exit 1 } @@ -50,12 +51,7 @@ case $key in esac done -if [ $ACTION != 'test' ] && [ $ACTION != 'run' ] && [ $ACTION != 'both' ] -then - display_usage -fi - -if [[ $TYPE == 'all' ]] +if { [ "$TYPE" == 'all' ]; } then TYPE="frequency" run_pipeline @@ -63,17 +59,25 @@ then TYPE="periodic" run_pipeline python tests/scripts/run_tests.py periodic + TYPE="event" + run_pipeline + python tests/scripts/run_tests.py event else - if [ $TYPE != 'frequency' ] && [ $TYPE != 'periodic' ] && [ $TYPE != 'event' ] + if { [ "$ACTION" != 'test' ] && [ "$ACTION" != 'run' ] && [ "$ACTION" != 'both' ]; } then display_usage fi - if { [ $ACTION == 'run' ] || [ $ACTION == 'both' ]; } + if { [ "$TYPE" != 'frequency' ] && [ "$TYPE" != 'periodic' ] && [ "$TYPE" != 'event' ]; } + then + display_usage + fi + + if { [ "$ACTION" == 'run' ] || [ "$ACTION" == 'both' ]; } then run_pipeline fi - if { [ $ACTION == 'test' ] || [ $ACTION == 'both' ]; } + if { [ "$ACTION" == 'test' ] || [ "$ACTION" == 'both' ]; } then python tests/scripts/run_tests.py $(echo $TYPE) fi