Changeset - da43302b84a7
[Not reviewed]
0 1 0
Branko Majic (branko) - 9 days ago 2024-09-18 13:46:27
branko@majic.rs
MAR-218: Improve linter reporting in the test runner script:

- Show info messages on what linter is currently running, and
explicitly report success and failure.
1 file changed with 22 insertions and 3 deletions:
0 comments (0 inline, 0 general)
scripts/run_tests.sh
Show inline comments
 
@@ -291,23 +291,42 @@ for role in "${roles_to_test[@]}"; do
 
        error "Failed to switch to directory: $role_dir"
 
    fi
 

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

	
 
        info "Executing linter (Flake8) on files found in $role_dir" 2>&1 | tee -a "$report_file"
 
        flake8 . 2>&1 | tee -a "$report_file"
 
        last_pipe_status="${PIPESTATUS[0]}"
 
        [[ $last_pipe_status == 0 ]] || role_test_result="$last_pipe_status"
 
        if [[ $last_pipe_status == 0 ]]; then
 
            success "Linter completed successfully." 2>&1 | tee -a "$report_file"
 
        else
 
            error "Linter (Flake8) failed." 2>&1 | tee -a "$report_file"
 
            role_test_result="$last_pipe_status"
 
        fi
 

	
 
        info "Executing linter (yamllint) on files found in $role_dir" 2>&1 | tee -a "$report_file"
 
        yamllint . 2>&1 | tee -a "$report_file"
 
        last_pipe_status="${PIPESTATUS[0]}"
 
        [[ $last_pipe_status == 0 ]] || role_test_result="$last_pipe_status"
 
        if [[ $last_pipe_status == 0 ]]; then
 
            success "Linter completed successfully." 2>&1 | tee -a "$report_file"
 
        else
 
            error "Linter (yamllint) failed." 2>&1 | tee -a "$report_file"
 
            role_test_result="$last_pipe_status"
 
        fi
 

	
 
        info "Executing linter (ansible-lint) on files found in $role_dir" 2>&1 | tee -a "$report_file"
 
        ansible-lint -q . 2>&1 | tee -a "$report_file"
 
        last_pipe_status="${PIPESTATUS[0]}"
 
        [[ $last_pipe_status == 0 ]] || role_test_result="$last_pipe_status"
 
        if [[ $last_pipe_status == 0 ]]; then
 
            success "Linter completed successfully." 2>&1 | tee -a "$report_file"
 
        else
 
            error "Linter (ansible-lint) failed." 2>&1 | tee -a "$report_file"
 
            role_test_result="$last_pipe_status"
 
        fi
 

	
 
    fi
 

	
 
    # Run the unit/functional tests (if requested).
 
    if [[ $role_test_result == 0 && $tests == all ]]; then
 

	
 
        molecule test --destroy always 2>&1 | tee -a "$report_file"
0 comments (0 inline, 0 general)