Changeset - b4004db97776
[Not reviewed]
0 1 0
Branko Majic (branko) - 17 days ago 2024-09-09 23:52:23
branko@majic.rs
MAR-218: Fix incorrect logic for switching directory:

- No piping can be used (since that would be a subshell and would not
affect the working directory for the remainder of the script run).
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
scripts/run_tests.sh
Show inline comments
 
@@ -279,19 +279,20 @@ for role in "${roles_to_test[@]}"; do
 
    else
 
        report_file="/dev/null"
 
    fi
 

	
 
    info "Running tests for: $role"
 

	
 
    # Assume success. This variable gets updated in case of failures.
 
    role_test_result=0
 

	
 
    # Switch directory, make sure it is successful.
 
    # shellcheck disable=SC2164  # failed directory switch is dealt with additional checks below.
 
    cd "$role_dir" 2>&1 | tee -a "$report_file"
 
    last_pipe_status="${PIPESTATUS[0]}"
 
    [[ $last_pipe_status == 0 ]] || role_test_result="$last_pipe_status"
 
    if ! cd "$role_dir" >> "$report_file" 2>&1; then
 
        role_test_result=1
 
        error "Failed to switch to directory: $role_dir"
 
    fi
 

	
 
    # Run the linters.
 
    if [[ $role_test_result == 0 ]]; then
 

	
 
        flake8 . 2>&1 | tee -a "$report_file"
 
        last_pipe_status="${PIPESTATUS[0]}"
0 comments (0 inline, 0 general)