From a65f16dd088b8c7b51703df17628f85271d1bcde Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 27 Jan 2023 22:47:53 +0100 Subject: [PATCH] Moar refactoring --- lib/lxc.sh | 2 +- lib/tests.sh | 6 +++--- lib/tests_coordination.sh | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/lxc.sh b/lib/lxc.sh index 5869067..82a4ee1 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -97,7 +97,7 @@ LXC_EXEC () { start_timer # Execute the command given in argument in the container and log its results. - lxc exec $LXC_NAME --env PACKAGE_CHECK_EXEC=1 -t -- /bin/bash -c "$cmd" | tee -a "$complete_log" $current_test_log + lxc exec $LXC_NAME --env PACKAGE_CHECK_EXEC=1 -t -- /bin/bash -c "$cmd" | tee -a "$full_log" $current_test_log # Store the return code of the command local returncode=${PIPESTATUS[0]} diff --git a/lib/tests.sh b/lib/tests.sh index ecd16a9..5fe7a31 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -277,7 +277,7 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () { then # Print the title of the page local page_title=$(grep "" "$curl_output" | cut --delimiter='>' --fields=2 | cut --delimiter='<' --fields=1) - local page_extract=$(lynx -dump -force_html "$curl_output" | head --lines 20 | tee -a "$complete_log") + local page_extract=$(lynx -dump -force_html "$curl_output" | head --lines 20 | tee -a "$full_log") # Check if the page title is neither the YunoHost portail or default NGINX page if [ "$page_title" = "YunoHost Portal" ] @@ -355,8 +355,8 @@ TEST_PACKAGE_LINTER () { start_test "Package linter" # Execute package linter and linter_result gets the return code of the package linter - ./package_linter/package_linter.py "$package_path" | tee -a "$complete_log" - ./package_linter/package_linter.py "$package_path" --json | tee -a "$complete_log" > $current_test_results + ./package_linter/package_linter.py "$package_path" | tee -a "$full_log" + ./package_linter/package_linter.py "$package_path" --json | tee -a "$full_log" > $current_test_results return ${PIPESTATUS[0]} } diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index 7fefd3a..59fcc66 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -5,13 +5,17 @@ source lib/tests.sh source lib/witness.sh source lib/legacy.sh -readonly complete_log="./Complete-${WORKER_ID}.log" +readonly full_log="./full_log_${WORKER_ID}.log" +readonly result_json="./results_${WORKER_ID}.json" +readonly summary_png="./summary_${WORKER_ID}.png" # Purge some log files -rm -f "$complete_log" && touch "$complete_log" +rm -f "$full_log" && touch "$full_log" +rm $result_json +rm $summary_png -# Redirect fd 3 (=debug steam) to complete log -exec 3>>$complete_log +# Redirect fd 3 (=debug steam) to full log +exec 3>>$full_log #================================================= # Misc test helpers & coordination @@ -84,8 +88,8 @@ run_all_tests() { # Print the final results of the tests log_title "Tests summary" - python3 lib/analyze_test_results.py $TEST_CONTEXT 2> ./results-${WORKER_ID}.json - [[ -e "$TEST_CONTEXT/summary.png" ]] && cp "$TEST_CONTEXT/summary.png" ./summary.png || rm -f summary.png + python3 lib/analyze_test_results.py $TEST_CONTEXT 2> $result_json + [[ -e "$TEST_CONTEXT/summary.png" ]] && cp "$TEST_CONTEXT/summary.png" $summary_png || rm -f $summary_png # Restore the started time for the timer starttime=$complete_start_timer