-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af81768
commit 2c202b8
Showing
30 changed files
with
505 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Title: Parallel testing | ||
|
||
* Status: accepted | ||
* Authors: @Chemaclass | ||
* Date: 2024-10-11 | ||
|
||
Technical Story: | ||
- Pull Request: [TypedDevs/bashunit#358](https://github.com/TypedDevs/bashunit/pull/358) | ||
|
||
## Context and Problem Statement | ||
|
||
We aim to enhance testing performance by running tests in parallel processes while capturing and aggregating results effectively. | ||
|
||
## Considered Options | ||
|
||
- Implement parallel execution using subprocesses. | ||
- Aggregate test results from temporary files. | ||
- Use a spinner for user feedback during result aggregation. | ||
|
||
## Decision Outcome | ||
|
||
- Implemented parallel test execution using subprocesses. | ||
- Each test creates a temporary directory to store results, later aggregated. | ||
|
||
### Positive Consequences | ||
|
||
- Reduced test execution time considerably. | ||
- Clear feedback via a spinner during aggregation. | ||
|
||
### Negative Consequences | ||
|
||
- Potential complexity | ||
- with handling temporary files during interruptions. | ||
- in handling temporary files and managing subprocesses. | ||
|
||
## Technical Details | ||
|
||
When the `--parallel` flag is used, each test is run in its own subprocess by calling: | ||
|
||
> runner::call_test_functions "$test_file" "$filter" 2>/dev/null & | ||
Each test script creates a temporary directory and stores individual test results in temp files. | ||
After all tests finish, the results are aggregated by traversing these directories and files. | ||
This approach ensures isolation of test execution while improving performance by running tests concurrently. | ||
|
||
The aggregation (which collects all test outcomes into a final result set) is handled by the function: | ||
|
||
> parallel::aggregate_test_results "$TEMP_DIR_PARALLEL_TEST_SUITE" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
function parallel::aggregate_test_results() { | ||
local temp_dir_parallel_test_suite=$1 | ||
|
||
local total_failed=0 | ||
local total_passed=0 | ||
local total_skipped=0 | ||
local total_incomplete=0 | ||
local total_snapshot=0 | ||
|
||
for script_dir in "$temp_dir_parallel_test_suite"/*; do | ||
for result_file in "$script_dir"/*.result; do | ||
while IFS= read -r line; do | ||
# Extract assertion counts from the result lines using sed | ||
failed=$(echo "$line" | sed -n 's/.*##ASSERTIONS_FAILED=\([0-9]*\)##.*/\1/p') | ||
passed=$(echo "$line" | sed -n 's/.*##ASSERTIONS_PASSED=\([0-9]*\)##.*/\1/p') | ||
skipped=$(echo "$line" | sed -n 's/.*##ASSERTIONS_SKIPPED=\([0-9]*\)##.*/\1/p') | ||
incomplete=$(echo "$line" | sed -n 's/.*##ASSERTIONS_INCOMPLETE=\([0-9]*\)##.*/\1/p') | ||
snapshot=$(echo "$line" | sed -n 's/.*##ASSERTIONS_SNAPSHOT=\([0-9]*\)##.*/\1/p') | ||
|
||
# Default to 0 if no match is found | ||
failed=${failed:-0} | ||
passed=${passed:-0} | ||
skipped=${skipped:-0} | ||
incomplete=${incomplete:-0} | ||
snapshot=${snapshot:-0} | ||
|
||
# Add to the total counts | ||
total_failed=$((total_failed + failed)) | ||
total_passed=$((total_passed + passed)) | ||
total_skipped=$((total_skipped + skipped)) | ||
total_incomplete=$((total_incomplete + incomplete)) | ||
total_snapshot=$((total_snapshot + snapshot)) | ||
done < "$result_file" | ||
|
||
if [ "${failed:-0}" -gt 0 ]; then | ||
state::add_tests_failed | ||
continue | ||
fi | ||
|
||
if [ "${snapshot:-0}" -gt 0 ]; then | ||
state::add_tests_snapshot | ||
continue | ||
fi | ||
|
||
if [ "${incomplete:-0}" -gt 0 ]; then | ||
state::add_tests_incomplete | ||
continue | ||
fi | ||
|
||
if [ "${skipped:-0}" -gt 0 ]; then | ||
state::add_tests_skipped | ||
continue | ||
fi | ||
|
||
state::add_tests_passed | ||
done | ||
done | ||
|
||
export _ASSERTIONS_FAILED=$total_failed | ||
export _ASSERTIONS_PASSED=$total_passed | ||
export _ASSERTIONS_SKIPPED=$total_skipped | ||
export _ASSERTIONS_INCOMPLETE=$total_incomplete | ||
export _ASSERTIONS_SNAPSHOT=$total_snapshot | ||
} |
Oops, something went wrong.