Skip to content

Commit 896e1eb

Browse files
authored
Improve JetBrains integration tests to show proper failed message (#20165)
* Improve JetBrains integration tests to show proper failed message * fixup: show stdout
1 parent 0be8880 commit 896e1eb

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

test/tests/ide/jetbrains/gateway_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,16 @@ func TestIntelliJWarmup(t *testing.T) {
275275
string(warmupIndexingShell),
276276
"--",
277277
jbCtx.SystemDir,
278+
"1",
278279
},
279280
}, &resp)
280281
if err != nil {
281282
return fmt.Errorf("failed to warmup indexing: %v", err)
282283
}
284+
t.Logf("stdout:\n%s", string(resp.Stdout))
283285
if resp.ExitCode != 0 {
284286
return fmt.Errorf("failed to warmup indexing: %s, %d", resp.Stderr, resp.ExitCode)
285287
}
286-
t.Logf("output:\n%s", string(resp.Stdout))
287288
return nil
288289
}))
289290
return testCtx

test/tests/ide/jetbrains/warmup-indexing.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
# This script is used to test JetBrains prebuild warmup indexing (search warmup-indexing.sh in codebase)
77
# It will get the last indexing json file (scan type FULL_ON_PROJECT_OPEN)
8-
# and check if the scheduled indexing count is 0
8+
# and check if the scheduled indexing count is greater than a specified threshold
99
#
1010
# `exit 0` means JetBrains IDEs no need to indexing again
11+
# Example: ./warmup-indexing.sh /workspace 1
1112

1213
set -euo pipefail
1314
SystemDir=$1
15+
Threshold=$2
1416

1517
ProjectIndexingFolder=$(find "$SystemDir"/log/indexing-diagnostic -type d -name "spring*" -print -quit)
1618
JsonFiles=$(find "$ProjectIndexingFolder" -type f -name "*.json")
@@ -26,6 +28,11 @@ mapfile -t sortedFiles < <(printf "%s\n" "${FilteredJsonFiles[@]}" | sort -r)
2628
targetFile=${sortedFiles[0]}
2729
echo "Target indexing json file: $targetFile"
2830
scheduledIndexing=$(jq '.projectIndexingActivityHistory.fileCount.numberOfFilesScheduledForIndexingAfterScan' "$targetFile")
29-
echo "Scheduled indexing count: $scheduledIndexing"
31+
echo "Scheduled indexing count: $scheduledIndexing, threshold: $Threshold"
3032

31-
[ "$scheduledIndexing" -ne 0 ] && exit 1 || exit 0
33+
if [ "$scheduledIndexing" -gt "$Threshold" ]; then
34+
echo "Error: Scheduled indexing count $scheduledIndexing > $Threshold" >&2
35+
exit 1
36+
else
37+
exit 0
38+
fi

0 commit comments

Comments
 (0)