github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/run.sh (about) 1 #!/bin/bash -e 2 3 if [[ ! ${MY_PATH} ]]; 4 then 5 MY_PATH="`dirname \"$0\"`" # relative 6 MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized 7 fi 8 9 if [[ ! ${TIME_TO_QUERY} ]]; 10 then 11 TIME_TO_QUERY=4 12 fi 13 14 # set this to the source file for development 15 export BATS_PATH=$MY_PATH/lib/bats-core/bin/bats 16 export LIB=$MY_PATH/lib 17 export LIB_BATS_ASSERT=$LIB/bats-assert 18 export LIB_BATS_SUPPORT=$LIB/bats-support 19 export TEST_DATA_DIR=$MY_PATH/test_data/templates 20 export SNAPSHOTS_DIR=$MY_PATH/test_data/snapshots 21 export SRC_DATA_DIR=$MY_PATH/test_data/source_files 22 export WORKSPACE_DIR=$MY_PATH/test_data/mods/sample_workspace 23 export BAD_TEST_MOD_DIR=$MY_PATH/test_data/mods/failure_test_mod 24 export TIME_TO_QUERY=$TIME_TO_QUERY 25 export SIMPLE_MOD_DIR=$MY_PATH/test_data/mods/introspection_table_mod 26 export CONFIG_PARSING_TEST_MOD=$MY_PATH/test_data/mods/config_parsing_test_mod 27 export FILE_PATH=$MY_PATH 28 export CHECK_ALL_MOD=$MY_PATH/test_data/mods/check_all_mod 29 export FUNCTIONALITY_TEST_MOD=$MY_PATH/test_data/mods/functionality_test_mod 30 export CONTROL_RENDERING_TEST_MOD=$MY_PATH/test_data/mods/control_rendering_test_mod 31 export BLANK_DIMENSION_VALUE_TEST_MOD=$MY_PATH/test_data/mods/mod_with_blank_dimension_value 32 export STRING_LIST_TEST_MOD=$MY_PATH/test_data/mods/mod_with_list_param 33 export STEAMPIPE_CONNECTION_WATCHER=false 34 export STEAMPIPE_INTROSPECTION=info 35 export DEFAULT_WORKSPACE_PROFILE_LOCATION=$MY_PATH/test_data/source_files/workspace_profile_default 36 # from GH action env variables 37 export SPIPETOOLS_PG_CONN_STRING=$SPIPETOOLS_PG_CONN_STRING 38 export SPIPETOOLS_TOKEN=$SPIPETOOLS_TOKEN 39 # Disable parallelisation only within test file(for steampipe plugin manager processes to shutdown properly) 40 export BATS_NO_PARALLELIZE_WITHIN_FILE=true 41 export BATS_TEST_TIMEOUT=180 42 43 # Must have these commands for the test suite to run 44 declare -a required_commands=("jq" "sed" "steampipe" "rm" "mv" "cp" "mkdir" "cd" "head" "wc" "find" "basename" "dirname" "touch" "jd" "openssl" "cksum") 45 46 for required_command in "${required_commands[@]}" 47 do 48 if [[ $(command -v $required_command | head -c1 | wc -c) -eq 0 ]]; then 49 echo "$required_command is required for this test suite to run." 50 exit -1 51 fi 52 done 53 54 echo " ____ _ _ _ _____ _ " 55 echo "/ ___|| |_ __ _ _ __| |_(_)_ __ __ _ |_ _|__ ___| |_ ___ " 56 echo "\___ \| __/ _\` | '__| __| | '_ \ / _\` | | |/ _ \/ __| __/ __|" 57 echo " ___) | || (_| | | | |_| | | | | (_| | | | __/\__ \ |_\__ \\" 58 echo "|____/ \__\__,_|_| \__|_|_| |_|\__, | |_|\___||___/\__|___/" 59 echo " |___/ " 60 61 export PATH=$MY_PATH/lib/bats-core/bin:$PATH 62 63 if [[ ! ${STEAMPIPE_INSTALL_DIR} ]]; 64 then 65 export STEAMPIPE_INSTALL_DIR="$HOME/.steampipe" 66 fi 67 68 batversion=$(bats --version) 69 echo $batversion 70 echo "Running with STEAMPIPE_INSTALL_DIR set to: $STEAMPIPE_INSTALL_DIR" 71 echo "Running with binary from: $(which steampipe)" 72 73 if [ $# -eq 0 ]; then 74 # Run all test files 75 bats --tap $MY_PATH/test_files 76 else 77 # Run a single test file 78 bats --tap $MY_PATH/test_files/${1} 79 fi