Only run unit tests when core Spack framework is modified
This commit is contained in:
		
							
								
								
									
										32
									
								
								share/spack/qa/check_dependencies
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										32
									
								
								share/spack/qa/check_dependencies
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Description:
 | 
				
			||||||
 | 
					#     Check to see if dependencies are installed.
 | 
				
			||||||
 | 
					#     If not, warn the user and tell them how to
 | 
				
			||||||
 | 
					#     install these dependencies.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Usage:
 | 
				
			||||||
 | 
					#     check-deps <dep> ...
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Options:
 | 
				
			||||||
 | 
					#     One or more dependencies. Must use name of binary.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for dep in "$@"; do
 | 
				
			||||||
 | 
					    if ! which $dep &> /dev/null; then
 | 
				
			||||||
 | 
					        # sphinx-build comes from sphinx
 | 
				
			||||||
 | 
					        package=$(echo $dep | cut -d - -f 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        cat << EOF
 | 
				
			||||||
 | 
					ERROR: $package is required to run this script.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					To install with Spack, run:
 | 
				
			||||||
 | 
					    $ spack install py-$package
 | 
				
			||||||
 | 
					or, to install with pip, run:
 | 
				
			||||||
 | 
					    $ pip install $package
 | 
				
			||||||
 | 
					Then add the bin directory to your PATH.
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "Dependencies found."
 | 
				
			||||||
@@ -9,32 +9,37 @@
 | 
				
			|||||||
#     run-doc-tests
 | 
					#     run-doc-tests
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Notes:
 | 
					# Notes:
 | 
				
			||||||
#     Requires sphinx. Can be installed by running:
 | 
					#     Requires sphinx and mercurial.
 | 
				
			||||||
#         `spack install py-sphinx`
 | 
					 | 
				
			||||||
#     or:
 | 
					 | 
				
			||||||
#         `pip install sphinx`
 | 
					 | 
				
			||||||
#     and adding the bin directory to your PATH.
 | 
					 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QA_DIR="$(dirname "$0")"
 | 
					QA_DIR="$(dirname "$0")"
 | 
				
			||||||
SPACK_ROOT="$QA_DIR/../../.."
 | 
					SPACK_ROOT="$QA_DIR/../../.."
 | 
				
			||||||
DOC_DIR="$SPACK_ROOT/lib/spack/docs"
 | 
					DOC_DIR="$SPACK_ROOT/lib/spack/docs"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Move to documentation directory
 | 
					# Array of dependencies
 | 
				
			||||||
# Allows script to be run from anywhere
 | 
					deps=(
 | 
				
			||||||
cd "$DOC_DIR"
 | 
					    sphinx-build
 | 
				
			||||||
 | 
					    hg
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check for dependencies
 | 
				
			||||||
 | 
					"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Gather array of changed files
 | 
					# Gather array of changed files
 | 
				
			||||||
changed=($("$QA_DIR/changed_files" lib/spack/docs))
 | 
					changed=($("$QA_DIR/changed_files" lib/spack/docs))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Move to documentation directory
 | 
				
			||||||
 | 
					# Allows script to be run from anywhere
 | 
				
			||||||
 | 
					cd "$DOC_DIR"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Cleanup temporary files upon exit or when script is killed
 | 
					# Cleanup temporary files upon exit or when script is killed
 | 
				
			||||||
trap 'make clean' EXIT SIGINT SIGTERM
 | 
					trap 'make clean --silent' EXIT SIGINT SIGTERM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Only run tests if documentation was updated
 | 
					# Only run tests if documentation was updated
 | 
				
			||||||
if [[ "${changed[@]}" ]]; then
 | 
					if [[ "${changed[@]}" ]]; then
 | 
				
			||||||
    # Treat warnings as fatal errors
 | 
					    # Treat warnings as fatal errors
 | 
				
			||||||
    make SPHINXOPTS=-W
 | 
					    make SPHINXOPTS=-W
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
    echo No documentation was modified.
 | 
					    echo "No documentation was modified."
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,23 +9,20 @@
 | 
				
			|||||||
#     run-flake8-tests
 | 
					#     run-flake8-tests
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Notes:
 | 
					# Notes:
 | 
				
			||||||
#     Requires flake8. Can be installed by running:
 | 
					#     Requires flake8.
 | 
				
			||||||
#         `spack install py-flake8`
 | 
					 | 
				
			||||||
#     or:
 | 
					 | 
				
			||||||
#         `pip install flake8`
 | 
					 | 
				
			||||||
#     and adding the bin directory to your PATH.
 | 
					 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check for dependencies
 | 
					 | 
				
			||||||
flake8="$(which flake8)"
 | 
					 | 
				
			||||||
if [[ ! $flake8 ]]; then
 | 
					 | 
				
			||||||
    echo "ERROR: flake8 is required to run this script."
 | 
					 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
QA_DIR="$(dirname "$0")"
 | 
					QA_DIR="$(dirname "$0")"
 | 
				
			||||||
SPACK_ROOT="$QA_DIR/../../.."
 | 
					SPACK_ROOT="$QA_DIR/../../.."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Array of dependencies
 | 
				
			||||||
 | 
					deps=(
 | 
				
			||||||
 | 
					    flake8
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check for dependencies
 | 
				
			||||||
 | 
					"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Move to root directory of Spack
 | 
					# Move to root directory of Spack
 | 
				
			||||||
# Allows script to be run from anywhere
 | 
					# Allows script to be run from anywhere
 | 
				
			||||||
cd "$SPACK_ROOT"
 | 
					cd "$SPACK_ROOT"
 | 
				
			||||||
@@ -33,6 +30,12 @@ cd "$SPACK_ROOT"
 | 
				
			|||||||
# Gather array of changed files
 | 
					# Gather array of changed files
 | 
				
			||||||
changed=($("$QA_DIR/changed_files" "*.py"))
 | 
					changed=($("$QA_DIR/changed_files" "*.py"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Exit if no Python files were modified
 | 
				
			||||||
 | 
					if [[ ! "${changed[@]}" ]]; then
 | 
				
			||||||
 | 
					    echo "No Python files were modified."
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function cleanup {
 | 
					function cleanup {
 | 
				
			||||||
    # Restore original package files after modifying them.
 | 
					    # Restore original package files after modifying them.
 | 
				
			||||||
    for file in "${changed[@]}"; do
 | 
					    for file in "${changed[@]}"; do
 | 
				
			||||||
@@ -55,15 +58,15 @@ for file in "${changed[@]}"; do
 | 
				
			|||||||
    #
 | 
					    #
 | 
				
			||||||
    if [[ $file = *package.py ]]; then
 | 
					    if [[ $file = *package.py ]]; then
 | 
				
			||||||
        # Exempt lines with urls and descriptions from overlong line errors.
 | 
					        # Exempt lines with urls and descriptions from overlong line errors.
 | 
				
			||||||
        perl -i -pe 's/^(\s*homepage\s*=.*)$/\1  # NOQA: ignore=E501/' $file
 | 
					        perl -i -pe 's/^(\s*homepage\s*=.*)$/\1  # NOQA: ignore=E501/' "$file"
 | 
				
			||||||
        perl -i -pe 's/^(\s*url\s*=.*)$/\1  # NOQA: ignore=E501/' $file
 | 
					        perl -i -pe 's/^(\s*url\s*=.*)$/\1  # NOQA: ignore=E501/' "$file"
 | 
				
			||||||
        perl -i -pe 's/^(\s*version\(.*\).*)$/\1  # NOQA: ignore=E501/' $file
 | 
					        perl -i -pe 's/^(\s*version\(.*\).*)$/\1  # NOQA: ignore=E501/' "$file"
 | 
				
			||||||
        perl -i -pe 's/^(\s*variant\(.*\).*)$/\1  # NOQA: ignore=E501/' $file
 | 
					        perl -i -pe 's/^(\s*variant\(.*\).*)$/\1  # NOQA: ignore=E501/' "$file"
 | 
				
			||||||
        perl -i -pe 's/^(\s*depends_on\(.*\).*)$/\1  # NOQA: ignore=E501/' $file
 | 
					        perl -i -pe 's/^(\s*depends_on\(.*\).*)$/\1  # NOQA: ignore=E501/' "$file"
 | 
				
			||||||
        perl -i -pe 's/^(\s*extends\(.*\).*)$/\1  # NOQA: ignore=E501/' $file
 | 
					        perl -i -pe 's/^(\s*extends\(.*\).*)$/\1  # NOQA: ignore=E501/' "$file"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Exempt '@when' decorated functions from redefinition errors.
 | 
					        # Exempt '@when' decorated functions from redefinition errors.
 | 
				
			||||||
        perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1  # NOQA: ignore=F811/' $file
 | 
					        perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1  # NOQA: ignore=F811/' "$file"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
@@ -72,21 +75,15 @@ for file in "${changed[@]}"; do
 | 
				
			|||||||
    perl -i -pe 's/^(.*(https?|file)\:.*)$/\1  # NOQA: ignore=E501/' $file
 | 
					    perl -i -pe 's/^(.*(https?|file)\:.*)$/\1  # NOQA: ignore=E501/' $file
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ "${changed[@]}" ]]; then
 | 
					echo =======================================================
 | 
				
			||||||
    echo =======================================================
 | 
					echo  flake8: running flake8 code checks on spack.
 | 
				
			||||||
    echo  flake8: running flake8 code checks on spack.
 | 
					echo
 | 
				
			||||||
    echo
 | 
					echo  Modified files:
 | 
				
			||||||
    echo  Modified files:
 | 
					echo  "${changed[@]}" | perl -pe 's/^/  /;s/ +/\n  /g'
 | 
				
			||||||
    echo  "${changed[@]}" | perl -pe 's/^/  /;s/ +/\n  /g'
 | 
					echo =======================================================
 | 
				
			||||||
    echo =======================================================
 | 
					if flake8 --format pylint "${changed[@]}"; then
 | 
				
			||||||
    if flake8 --format pylint "${changed[@]}"; then
 | 
					    echo "Flake8 checks were clean."
 | 
				
			||||||
        echo "Flake8 checks were clean."
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        echo "Flake8 found errors."
 | 
					 | 
				
			||||||
        exit 1
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
    echo No Python files were modified.
 | 
					    echo "Flake8 found errors."
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					 | 
				
			||||||
exit 0
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,20 +1,60 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# This script runs Spack unit tests.
 | 
					# Description:
 | 
				
			||||||
 | 
					#     Runs Spack unit tests.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# It should be executed from the top-level directory of the repo,
 | 
					# Usage:
 | 
				
			||||||
# e.g.:
 | 
					#     run-unit-tests [test ...]
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#    share/spack/qa/run-unit-tests
 | 
					# Options:
 | 
				
			||||||
 | 
					#     Optionally add one or more unit tests
 | 
				
			||||||
 | 
					#     to only run these tests.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# To run it, you'll need to have the Python coverage installed locally.
 | 
					# Notes:
 | 
				
			||||||
 | 
					#     Requires coverage.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Regular spack setup and tests
 | 
					QA_DIR="$(dirname "$0")"
 | 
				
			||||||
. ./share/spack/setup-env.sh
 | 
					SPACK_ROOT="$QA_DIR/../../.."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Array of dependencies
 | 
				
			||||||
 | 
					deps=(
 | 
				
			||||||
 | 
					    coverage
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check for dependencies
 | 
				
			||||||
 | 
					"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Add Spack to the PATH.
 | 
				
			||||||
 | 
					export PATH="$SPACK_ROOT/bin:$PATH"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Array of directories containing core Spack framework
 | 
				
			||||||
 | 
					core_dirs=(
 | 
				
			||||||
 | 
					    bin
 | 
				
			||||||
 | 
					    etc
 | 
				
			||||||
 | 
					    # lib, but skip documentation
 | 
				
			||||||
 | 
					    lib/spack/env
 | 
				
			||||||
 | 
					    lib/spack/external
 | 
				
			||||||
 | 
					    lib/spack/llnl
 | 
				
			||||||
 | 
					    lib/spack/spack
 | 
				
			||||||
 | 
					    share
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Gather array of changed files
 | 
				
			||||||
 | 
					changed=($("$QA_DIR/changed_files" "${core_dirs[@]}"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Exit if no core Spack framework files were modified
 | 
				
			||||||
 | 
					if [[ ! "${changed[@]}" ]]; then
 | 
				
			||||||
 | 
					    echo "No core Spack framework files were modified."
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Run integration tests
 | 
				
			||||||
 | 
					# TODO: should these be separated into a different test suite?
 | 
				
			||||||
 | 
					source "$SPACK_ROOT/share/spack/setup-env.sh"
 | 
				
			||||||
spack compilers
 | 
					spack compilers
 | 
				
			||||||
spack config get compilers
 | 
					spack config get compilers
 | 
				
			||||||
spack install -v libdwarf
 | 
					spack install -v libdwarf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Run unit tests with code coverage
 | 
					# Run unit tests with code coverage
 | 
				
			||||||
coverage run bin/spack test
 | 
					coverage run spack test "$@"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user