Skip to content

Commit 1db04d8

Browse files
ci: Print slowest test cases (#2970)
Print the 20 slowest test cases after running unit tests.
1 parent 21fd61f commit 1db04d8

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ jobs:
204204
# manipulating string in expressions.
205205
run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} $GITHUB_REF_NAME ci test-without-building
206206

207+
- name: Slowest Tests
208+
if: ${{ always() }}
209+
run: ./scripts/xcode-slowest-tests.sh
210+
207211
- name: Archiving DerivedData Logs
208212
uses: actions/upload-artifact@v3
209213
if: failure()

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ GIT-REF := $(shell git rev-parse --abbrev-ref HEAD)
4545
test:
4646
@echo "--> Running all tests"
4747
./scripts/xcode-test.sh iOS latest $(GIT-REF) YES
48+
./scripts/xcode-slowest-tests.sh
4849
.PHONY: test
4950

5051
run-test-server:

scripts/xcode-slowest-tests.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Finds the x amount of slowest test cases in the raw-test-output.log file.
4+
# Logic copied from https://stanislaw.github.io/2016/08/04/how-to-find-the-slowest-xctest.html.
5+
6+
RAW_TEST_OUTPUT_LOG=${1:-raw-test-output.log}
7+
NUMBER_OF_SLOWEST_TEST="${2:-20}"
8+
9+
echo "The $NUMBER_OF_SLOWEST_TEST slowest test cases:"
10+
cat $RAW_TEST_OUTPUT_LOG | grep 'Test\ Case.*seconds' | awk -F '[()]' '{print $2 " -> " $1}' | sort -rn | head -n $NUMBER_OF_SLOWEST_TEST

0 commit comments

Comments
 (0)