Skip to content

Commit 68f89d4

Browse files
committed
[SourceKit] Fix flakey VFS completion tests
These tests relied on timing between completion runs in order to check that fast completion was working properly for completions in VFS files. That is, they would assume that two runs happening one after another without a sleep inbetween would always run fast completion. However, that's not necessarily the case and there have been cases where a dependency check happens despite its interval being fairly long (multi-second). This change emulates the same behaviour by changing the interval between 0/100, which should prevent any timing issues. Resolves rdar://72144331
1 parent 6a5eb3c commit 68f89d4

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

test/SourceKit/CodeComplete/complete_checkdeps_vfs.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,30 @@ func foo(value: MyStruct) {
44

55
// REQUIRES: shell
66

7-
// RUN: DEPCHECK_INTERVAL=2
8-
// RUN: SLEEP_TIME=3
9-
107
// RUN: %empty-directory(%t)
118
// RUN: %empty-directory(%t/VFS)
129
// RUN: cp %S/Inputs/checkdeps/MyProject/LibraryExt.swift %t/VFS/
1310

1411
// RUN: %sourcekitd-test \
15-
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=${DEPCHECK_INTERVAL} == \
12+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=100 == \
1613

1714
// RUN: -shell -- echo "### Initial" == \
1815
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
1916

2017
// RUN: -shell -- echo "### Modify" == \
21-
// RUN: -shell -- sleep ${SLEEP_TIME} == \
18+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=0 == \
2219
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
2320

2421
// RUN: -shell -- echo "### Keep" == \
25-
// RUN: -shell -- sleep ${SLEEP_TIME} == \
22+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=0 == \
2623
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
2724

28-
// RUN: -shell -- echo "### Rollback without sleep" == \
25+
// RUN: -shell -- echo "### Rollback without check" == \
26+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=100 == \
2927
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
3028

31-
// RUN: -shell -- echo "### After sleep" == \
32-
// RUN: -shell -- sleep ${SLEEP_TIME} == \
29+
// RUN: -shell -- echo "### Check" == \
30+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=0 == \
3331
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift \
3432

3533
// RUN: | %FileCheck %s
@@ -58,15 +56,15 @@ func foo(value: MyStruct) {
5856
// CHECK: ]
5957
// CHECK: key.reusingastcontext: 1
6058

61-
// CHECK-LABEL: ### Rollback without sleep
59+
// CHECK-LABEL: ### Rollback without check
6260
// CHECK: key.results: [
6361
// CHECK-DAG: key.description: "myStructMethod_mod()"
6462
// CHECK-DAG: key.description: "extensionMethod()"
6563
// CHECK-DAG: key.description: "self"
6664
// CHECK: ]
6765
// CHECK: key.reusingastcontext: 1
6866

69-
// CHECK-LABEL: ### After sleep
67+
// CHECK-LABEL: ### Check
7068
// CHECK: key.results: [
7169
// CHECK-DAG: key.description: "myStructMethod()"
7270
// CHECK-DAG: key.description: "extensionMethod()"

test/SourceKit/CodeComplete/complete_checkdeps_vfs_open.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,24 @@ func foo(value: MyStruct) {
44

55
// REQUIRES: shell
66

7-
// RUN: DEPCHECK_INTERVAL=1
8-
// RUN: SLEEP_TIME=2
9-
107
// RUN: %empty-directory(%t)
118
// RUN: %empty-directory(%t/VFS)
129
// RUN: cp %S/Inputs/checkdeps/MyProject/LibraryExt.swift %t/VFS/
1310

1411
// RUN: %sourcekitd-test \
15-
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=${DEPCHECK_INTERVAL} == \
12+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=100 == \
1613

1714
// RUN: -shell -- echo "### Initial" == \
1815
// RUN: -req=complete.open -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
1916
// RUN: -req=complete.close -pos=2:9 -name %t/VFS/Main.swift %s == \
2017

2118
// RUN: -shell -- echo "### Modify" == \
22-
// RUN: -shell -- sleep ${SLEEP_TIME} == \
19+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=0 == \
2320
// RUN: -req=complete.open -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
2421
// RUN: -req=complete.close -pos=2:9 -name %t/VFS/Main.swift %s == \
2522

2623
// RUN: -shell -- echo "### Keep" == \
24+
// RUN: -req=global-config -req-opts=completion_check_dependency_interval=100 == \
2725
// RUN: -req=complete.open -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/LibraryExt.swift %t/VFS/Library.swift == \
2826
// RUN: -req=complete.close -pos=2:9 -name %t/VFS/Main.swift %s \
2927

0 commit comments

Comments
 (0)