@@ -24,7 +24,7 @@ function allocate_testing_global -d "allocate global variables used for testing"
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function delete_testing_global -d "deallocate global varialbes used for testing"
 | 
					function delete_testing_global -d "deallocate global variables used for testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    set -e __spt_red
 | 
					    set -e __spt_red
 | 
				
			||||||
    set -e __spt_cyan
 | 
					    set -e __spt_cyan
 | 
				
			||||||
@@ -90,9 +90,12 @@ function spt_succeeds
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    set -l output (eval $argv 2>&1)
 | 
					    set -l output (eval $argv 2>&1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if test $status -ne 0
 | 
					    # Save the command result
 | 
				
			||||||
 | 
					    set cmd_status $status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if test $cmd_status -ne 0
 | 
				
			||||||
        fail
 | 
					        fail
 | 
				
			||||||
        echo_red "Command failed with error $status"
 | 
					        echo_red "Command failed with error $cmd_status"
 | 
				
			||||||
        if test -n "$output"
 | 
					        if test -n "$output"
 | 
				
			||||||
            echo_msg "Output:"
 | 
					            echo_msg "Output:"
 | 
				
			||||||
            echo "$output"
 | 
					            echo "$output"
 | 
				
			||||||
@@ -116,7 +119,7 @@ function spt_fails
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if test $status -eq 0
 | 
					    if test $status -eq 0
 | 
				
			||||||
        fail
 | 
					        fail
 | 
				
			||||||
        echo_red "Command failed with error $status"
 | 
					        echo_red "Command succeeded, but should fail"
 | 
				
			||||||
        if test -n "$output"
 | 
					        if test -n "$output"
 | 
				
			||||||
            echo_msg "Output:"
 | 
					            echo_msg "Output:"
 | 
				
			||||||
            echo "$output"
 | 
					            echo "$output"
 | 
				
			||||||
@@ -142,9 +145,14 @@ function spt_contains
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    set -l output (eval $remaining_args 2>&1)
 | 
					    set -l output (eval $remaining_args 2>&1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Save the command result
 | 
				
			||||||
 | 
					    set cmd_status $status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if not echo "$output" | string match -q -r ".*$target_string.*"
 | 
					    if not echo "$output" | string match -q -r ".*$target_string.*"
 | 
				
			||||||
        fail
 | 
					        fail
 | 
				
			||||||
        echo_red "Command exited with error $status"
 | 
					        if test $cmd_status -ne 0
 | 
				
			||||||
 | 
					            echo_red "Command exited with error $cmd_status"
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
        echo_red "'$target_string' was not in output."
 | 
					        echo_red "'$target_string' was not in output."
 | 
				
			||||||
        if test -n "$output"
 | 
					        if test -n "$output"
 | 
				
			||||||
            echo_msg "Output:"
 | 
					            echo_msg "Output:"
 | 
				
			||||||
@@ -249,13 +257,7 @@ echo "Creating a mock environment"
 | 
				
			|||||||
spack env create spack_test_env
 | 
					spack env create spack_test_env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ensure that we uninstall b on exit
 | 
					# ensure that we uninstall b on exit
 | 
				
			||||||
function spt_cleanup
 | 
					function spt_cleanup -p %self
 | 
				
			||||||
 | 
					 | 
				
			||||||
    set trapped_error false
 | 
					 | 
				
			||||||
    if test $status -ne 0
 | 
					 | 
				
			||||||
        set trapped_error true
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    echo "Removing test environment before exiting."
 | 
					    echo "Removing test environment before exiting."
 | 
				
			||||||
    spack env deactivate 2>&1 > /dev/null
 | 
					    spack env deactivate 2>&1 > /dev/null
 | 
				
			||||||
    spack env rm -y spack_test_env
 | 
					    spack env rm -y spack_test_env
 | 
				
			||||||
@@ -268,30 +270,9 @@ function spt_cleanup
 | 
				
			|||||||
    echo "$__spt_success tests succeeded."
 | 
					    echo "$__spt_success tests succeeded."
 | 
				
			||||||
    echo "$__spt_errors tests failed."
 | 
					    echo "$__spt_errors tests failed."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if test "$trapped_error" = false
 | 
					 | 
				
			||||||
        echo "Exited due to an error."
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if test "$__spt_errors" -eq 0
 | 
					 | 
				
			||||||
        if test "$trapped_error" = false
 | 
					 | 
				
			||||||
            pass
 | 
					 | 
				
			||||||
            exit 0
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
            fail
 | 
					 | 
				
			||||||
            exit 1
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        fail
 | 
					 | 
				
			||||||
        exit 1
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    delete_testing_global
 | 
					    delete_testing_global
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
trap spt_cleanup EXIT
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# -----------------------------------------------------------------------
 | 
					# -----------------------------------------------------------------------
 | 
				
			||||||
# Test all spack commands with special env support
 | 
					# Test all spack commands with special env support
 | 
				
			||||||
# -----------------------------------------------------------------------
 | 
					# -----------------------------------------------------------------------
 | 
				
			||||||
@@ -322,7 +303,6 @@ spt_contains "set -gx LD_LIBRARY_PATH $_b_ld" spack -m load --only package --fis
 | 
				
			|||||||
spt_succeeds spack -m load b
 | 
					spt_succeeds spack -m load b
 | 
				
			||||||
# test a variable MacOS clears and one it doesn't for recursive loads
 | 
					# test a variable MacOS clears and one it doesn't for recursive loads
 | 
				
			||||||
spt_contains "set -gx LD_LIBRARY_PATH $_a_ld:$_b_ld" spack -m load --fish a
 | 
					spt_contains "set -gx LD_LIBRARY_PATH $_a_ld:$_b_ld" spack -m load --fish a
 | 
				
			||||||
spt_contains "set -gx LIBRARY_PATH $_a_ld:$_b_ld" spack -m load --fish a
 | 
					 | 
				
			||||||
spt_succeeds spack -m load --only dependencies a
 | 
					spt_succeeds spack -m load --only dependencies a
 | 
				
			||||||
spt_succeeds spack -m load --only package a
 | 
					spt_succeeds spack -m load --only package a
 | 
				
			||||||
spt_fails spack -m load d
 | 
					spt_fails spack -m load d
 | 
				
			||||||
@@ -393,3 +373,5 @@ is_not_set SPACK_ENV
 | 
				
			|||||||
# despacktivate
 | 
					# despacktivate
 | 
				
			||||||
# is_not_set SPACK_ENV
 | 
					# is_not_set SPACK_ENV
 | 
				
			||||||
# is_not_set SPACK_OLD_PS1
 | 
					# is_not_set SPACK_OLD_PS1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test "$__spt_errors" -eq 0
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user