Skip to content

Commit 61b1f44

Browse files
committed
Merges two scripts for running functional tests into one
The new script allows running all the tests as well as selected tests
1 parent 7936535 commit 61b1f44

File tree

3 files changed

+27
-52
lines changed

3 files changed

+27
-52
lines changed

_assets/scripts/functional_tests_commons.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set_pyenv() {
2525
}
2626

2727
discover_tests() {
28-
pytest --collect-only -q -m rpc -c "${root_path}/pytest.ini" -k "$1"
28+
pytest --collect-only -q -m rpc -c "${root_path}/pytest.ini" "$1"
2929
}
3030

3131
start_services() {
@@ -87,25 +87,32 @@ wait_for_services() {
8787
}
8888

8989
list_tests_and_confirm() {
90-
# Discover tests first
91-
echo -e "${GRN}Discovering selected tests...${RST}"
92-
collected_output=$(discover_tests "$1")
90+
local selected_test="${1:+-k $1}"
91+
echo -e "${GRN}Discovering tests to be run...${RST}"
92+
collected_output=$(discover_tests "$selected_test")
9393
test_count=$(echo "$collected_output" | grep -c "^\s*<Function test_.*>$")
94-
95-
echo -e "${GRN}Found ${test_count} tests matching:${RST} $1"
96-
97-
# Early exit if no tests found
98-
if [ "$test_count" -eq "0" ]; then
94+
if [ -z "$selected_test" ]; then
95+
if [ "$test_count" -eq "0" ]; then
96+
echo -e "${RED}No tests found!${RST}"
97+
exit 1
98+
fi
99+
echo -e "${RED}No test pattern provided. This will run all ${test_count} tests!${RST}"
100+
else
101+
# Early exit if no tests found
102+
if [ "$test_count" -eq "0" ]; then
99103
echo -e "${RED}No tests found matching: $1${RST}"
100104
exit 1
105+
fi
106+
107+
echo -e "${GRN}Found ${test_count} tests matching:${RST} $1"
108+
109+
# Show the tests that will run
110+
echo -e "${GRN}Tests to execute:${RST}"
111+
echo "$collected_output" \
112+
| grep -oP "^\s*<Function \Ktest_[^>]*(?=>$)" \
113+
| nl -w2 -s') '
101114
fi
102-
103-
# Show the tests that will run
104-
echo -e "${GRN}Tests to execute:${RST}"
105-
echo "$collected_output" \
106-
| grep -oP "^\s*<Function \Ktest_[^>]*(?=>$)" \
107-
| nl -w2 -s') '
108-
115+
109116
read -p "Continue with execution? (y/n): " -n 1 -r
110117
echo
111118
if [[ ! $REPLY =~ ^[Yy]$ ]]; then

_assets/scripts/run_functional_one_test.sh renamed to _assets/scripts/run_functional_tests_dev.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ image_name="statusgo-${identifier}"
1818

1919
source "${GIT_ROOT}/_assets/scripts/functional_tests_commons.sh"
2020

21+
test_pattern="${1-}"
22+
2123
set_pyenv
2224

23-
list_tests_and_confirm "$1"
25+
list_tests_and_confirm "${test_pattern}"
2426

2527
remove_old_logs
2628

@@ -30,7 +32,7 @@ start_services
3032

3133
wait_for_services 60
3234

33-
run_tests "$1"
35+
run_tests "${test_pattern}"
3436

3537
# Cleanup will be handled automatically by the trap
3638
echo -e "${GRN}Testing finished${RST}"

_assets/scripts/run_functional_tests_no_cov.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)