diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2024-07-20 11:56:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-20 11:56:16 -0400 |
commit | 9489d31f6314322d26ec43196284b94069d6cd3a (patch) | |
tree | 3c314ff91b187faa2ba0f9ca2faf866d4fb97610 /tests | |
parent | 07dc44efdc5c2fbc2b34c969e623d3b0bc0df15a (diff) | |
download | stasis-9489d31f6314322d26ec43196284b94069d6cd3a.tar.gz |
Regression tests, envctl, and bug fixes (#13)
* Found too many bugs
* Implements a regression test
* Moves and completely refactors the envctl code
* Allows the user to keep @STR@ values in output files (if you want full control over where external packages comes from post-build)
* Fixes wording in a few places
* envctl redaction is not implemented yet. The original redaction code hasn't been modified.
* Use generic.ini instead of bare_minimum.ini
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/data/generic.ini | 51 | ||||
-rw-r--r-- | tests/rt_generic.sh | 87 |
3 files changed, 146 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f3a45e8..f06638e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,15 +2,20 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include ) +find_program(BASH_PROGRAM bash) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests) set(CTEST_BINARY_DIRECTORY ${PROJECT_BINARY_DIR}/tests) set(nix_gnu_cflags -Wno-error -Wno-unused-parameter -Wno-discarded-qualifiers) set(nix_clang_cflags -Wno-unused-parameter -Wno-incompatible-pointer-types-discards-qualifiers) set(win_msvc_cflags /Wall) - +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/generic.ini ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) file(GLOB files "test_*.c") +if (BASH_PROGRAM) + add_test (rt_generic ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/rt_generic.sh) +endif() + foreach(file ${files}) string(REGEX REPLACE "(^.*/|\\.[^.]*$)" "" file_without_ext ${file}) add_executable(${file_without_ext} ${file}) @@ -29,4 +34,6 @@ foreach(file ${files}) set_tests_properties(${file_without_ext} PROPERTIES SKIP_RETURN_CODE 127) + set_property(TEST ${file_without_ext} + PROPERTY ENVIRONMENT "STASIS_SYSCONFDIR=${CMAKE_SOURCE_DIR}") endforeach()
\ No newline at end of file diff --git a/tests/data/generic.ini b/tests/data/generic.ini new file mode 100644 index 0000000..ef0180b --- /dev/null +++ b/tests/data/generic.ini @@ -0,0 +1,51 @@ +[meta] +mission = generic +name = GENERIC +version = 1.2.3 +rc = 1 +final = false +based_on = +python = 3.11 + + +[conda] +installer_name = Miniforge3 +installer_version = 24.3.0-0 +installer_platform = {{env:STASIS_CONDA_PLATFORM}} +installer_arch = {{env:STASIS_CONDA_ARCH}} +installer_baseurl = https://github.com/conda-forge/miniforge/releases/download/{{conda.installer_version}} +;conda_packages = +pip_packages = + firewatch + + +[runtime] +PYTHONUNBUFFERED = 1 + + +[test:firewatch] +version = 0.0.4 +repository = https://github.com/astroconda/firewatch +script = + pip install -e '.' + + +[deploy:artifactory:delivery] +files = + {{ storage.output_dir }}/** +dest = {{ meta.mission }}/{{ info.build_name }}/ + + +[deploy:docker] +;registry = bytesalad.stsci.edu +image_compression = zstd -v -9 -c +build_args = + SNAPSHOT_INPUT={{ info.release_name }}.yml + SNAPSHOT_PKGDIR=packages +tags = + {{ meta.name }}:{{ info.build_number }}-py{{ meta.python_compact }} + {{ deploy.docker.registry }}/{{ meta.name }}:{{ info.build_number }}-py{{ meta.python_compact }} +test_script = + source /etc/profile + python -m pip freeze + mamba info diff --git a/tests/rt_generic.sh b/tests/rt_generic.sh new file mode 100644 index 0000000..200f66f --- /dev/null +++ b/tests/rt_generic.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +set -x +unset STASIS_SYSCONFDIR +if [ -n "$GITHUB_TOKEN" ] && [ -z "$STASIS_GH_TOKEN"]; then + export STASIS_GH_TOKEN="$GITHUB_TOKEN" +else + export STASIS_GH_TOKEN="anonymous" +fi + +topdir=$(pwd) + +ws="rt_workspace" +mkdir -p "$ws" +ws="$(realpath $ws)" + +prefix="$ws"/local +mkdir -p "$prefix" + +bdir="$ws"/build +mkdir -p "$bdir" + +pushd "$bdir" +cmake -DCMAKE_INSTALL_PREFIX="$prefix" "${topdir}"/../.. +make install +export PATH="$prefix/bin:$PATH" +popd + +pushd "$ws" + type -P stasis + type -P stasis_indexer + + stasis --no-docker --no-artifactory --unbuffered -v "$topdir"/generic.ini + retcode=$? + + set +x + + echo "#### Files ####" + find stasis/*/output | sort + echo + + echo "#### Contents ####" + files=$(find stasis/*/output -type f \( -name '*.yml' -o -name '*.md' -o -name '*.stasis' \) | sort) + for x in $files; do + echo + echo "FILENAME: $x" + echo + cat "$x" + echo "[EOF]" + echo + + fail_on_main=( + "(null)" + ) + for cond in "${fail_on_main[@]}"; do + if grep --color -H -n "$cond" "$x" >&2; then + echo "ERROR DETECTED IN $x!" >&2 + retcode=2 + fi + done + done + + # Something above failed, so drop out. Don't bother indexing. + # Don't clean up either. + (( retcode )) && exit $retcode + + fail_on_indexer=( + "(null)" + ) + logfile="stasis_indexer.log" + set -x + stasis_indexer --web --unbuffered -v stasis/* 2>&1 | tee "$logfile" + + set +x + find output + + for cond in "${fail_on_indexer[@]}"; do + if grep --color -H -n "$cond" "$logfile" >&2; then + echo "ERROR DETECTED IN INDEX OPERATION!" >&2 + exit 1 + fi + done + +popd + +rm -rf "$ws" + +exit $retcode
\ No newline at end of file |