FIX: Static variables all over the place for per patch
[csit.git] / resources / libraries / bash / function / per_patch.sh
index 83e8427..27fa0cf 100644 (file)
 
 set -exuo pipefail
 
-# This library defines functions used mainly by "per_patch_perf.sh" entry script.
+# This library defines functions used mainly by per patch entry scripts.
 # Generally, the functions assume "common.sh" library has been sourced already.
 
 # Keep functions ordered alphabetically, please.
 
-# TODO: Add a link to bash style guide.
-
-
-function archive_parse_test_results () {
+function archive_test_results () {
 
     set -exuo pipefail
 
     # Arguments:
     # - ${1}: Directory to archive to. Required. Parent has to exist.
+    # Variable set:
+    # - TARGET - Target directory.
     # Variables read:
     # - ARCHIVE_DIR - Path to where robot result files are created in.
     # - VPP_DIR - Path to existing directory, root for to relative paths.
@@ -34,17 +33,33 @@ function archive_parse_test_results () {
     # - ${1} - Created, and robot and parsing files are moved/created there.
     # Functions called:
     # - die - Print to stderr and exit, defined in common.sh
-    # - parse_bmrr_results - See definition in this file.
 
     cd "${VPP_DIR}" || die "Change directory command failed."
-    target="$(readlink -f "$1")"
-    mkdir -p "${target}" || die "Directory creation failed."
+    TARGET="$(readlink -f "$1")"
+    mkdir -p "${TARGET}" || die "Directory creation failed."
     for filename in "output.xml" "log.html" "report.html"; do
-        mv "${ARCHIVE_DIR}/${filename}" "${target}/${filename}" || {
+        mv "${ARCHIVE_DIR}/${filename}" "${TARGET}/${filename}" || {
             die "Attempt to move '${filename}' failed."
         }
     done
-    parse_bmrr_results "${target}" || {
+}
+
+
+function archive_parse_test_results () {
+
+    set -exuo pipefail
+
+    # Arguments:
+    # - ${1}: Directory to archive to. Required. Parent has to exist.
+    # Variables read:
+    # - TARGET - Target directory.
+    # Functions called:
+    # - die - Print to stderr and exit, defined in common.sh
+    # - archive_test_results - Archiving results.
+    # - parse_bmrr_results - See definition in this file.
+
+    archive_test_results "$1" || die
+    parse_bmrr_results "${TARGET}" || {
         die "The function should have died on error."
     }
 }