Skip to content

Commit

Permalink
Force unbuffered output
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Aug 2, 2024
1 parent 3940d8d commit 87c2215
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/coverage-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
cp -R src unit_tests
cp -R src feature_tests
- name: Install expect package
run: sudo apt-get install -y expect

- name: Create custom output formatter
run: |
cat << EOF > formatter.sh
Expand All @@ -57,12 +60,13 @@ jobs:
else
feature_progress+="\$result"
fi
echo -ne "\rUnit: \$unit_progress"
echo -ne "\nFeature: \$feature_progress"
echo -ne "\033[1A" # Move cursor up one line
printf "\rUnit: %-50s" "\$unit_progress"
printf "\nFeature: %-50s" "\$feature_progress"
printf "\033[1A" # Move cursor up one line
}
while IFS= read -r line; do
echo "\$line" >> "\$1_output.log"
if [[ \$line == *"[x]"* ]]; then
update_progress "\$1" "X"
elif [[ \$line == *"[✓]"* ]]; then
Expand All @@ -80,25 +84,25 @@ jobs:
# Start unit tests in the background
(
cd unit_tests
vendor/bin/pest --coverage-php=../coverage/unit.cov --testsuite=UnitFramework | tee unit_output.log | ../formatter.sh unit
unbuffer vendor/bin/pest --coverage-php=../coverage/unit.cov --testsuite=UnitFramework | unbuffer -p ../formatter.sh unit
) &
# Start feature tests in the background
(
cd feature_tests
vendor/bin/pest --coverage-php=../coverage/feature.cov --testsuite=FeatureHyde,FeatureFramework,Publications,"Realtime Compiler" | tee feature_output.log | ../formatter.sh feature
unbuffer vendor/bin/pest --coverage-php=../coverage/feature.cov --testsuite=FeatureHyde,FeatureFramework,Publications,"Realtime Compiler" | unbuffer -p ../formatter.sh feature
) &
# Wait for both background processes to finish
wait
- name: Print Unit Test Output
if: always()
run: cat unit_tests/unit_output.log
run: cat unit_output.log

- name: Print Feature Test Output
if: always()
run: cat feature_tests/feature_output.log
run: cat feature_output.log

- name: Download phpcov
run: wget https://phar.phpunit.de/phpcov.phar
Expand Down

0 comments on commit 87c2215

Please sign in to comment.