-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_conformance_tests_script.sh
More file actions
executable file
·68 lines (53 loc) · 1.7 KB
/
run_conformance_tests_script.sh
File metadata and controls
executable file
·68 lines (53 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
UNRECOVERABLE_ERROR_EXIT_CODE=69
# Check if build folder and conformance tests folder are provided
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Error: Missing arguments."
echo "Usage: $0 <build_folder_name> <conformance_tests_folder>"
exit $UNRECOVERABLE_ERROR_EXIT_CODE
fi
BUILD_FOLDER=$1
CONF_TESTS_FOLDER=$2
CURRENT_DIR=$(pwd)
PYTHON_BUILD_SUBFOLDER=".tmp/$1"
# Verify environment variables required for Slack interaction
if [ -z "$SLACK_BOT_TOKEN" ]; then
echo "Error: SLACK_BOT_TOKEN environment variable is not set."
exit $UNRECOVERABLE_ERROR_EXIT_CODE
fi
if [ -z "$SLACK_DM_ID" ]; then
echo "Error: SLACK_DM_ID environment variable is not set."
exit $UNRECOVERABLE_ERROR_EXIT_CODE
fi
echo "Preparing Conformance Test environment..."
# Setup build subfolder
if [ -d "$PYTHON_BUILD_SUBFOLDER" ]; then
find "$PYTHON_BUILD_SUBFOLDER" -mindepth 1 -exec rm -rf {} +
else
mkdir -p "$PYTHON_BUILD_SUBFOLDER"
fi
cp -R "$BUILD_FOLDER"/* "$PYTHON_BUILD_SUBFOLDER"
# Move to subfolder
cd "$PYTHON_BUILD_SUBFOLDER" || exit $UNRECOVERABLE_ERROR_EXIT_CODE
# Setup Virtual Environment
python3 -m venv venv
source venv/bin/activate
# Install requirements
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt
else
pip install slack_sdk python-dotenv
fi
# Run Conformance Tests
echo "Running Conformance Tests from: $CONF_TESTS_FOLDER"
# Conformance tests are run against the actual Slack API
output=$(python3 -m unittest discover -b -s "$CURRENT_DIR/$CONF_TESTS_FOLDER" 2>&1)
exit_code=$?
echo "$output"
# Check if no tests were discovered
if echo "$output" | grep -q "Ran 0 tests in"; then
echo "Error: No conformance tests discovered."
exit 1
fi
deactivate
exit $exit_code