Skip to content

Commit 11c448d

Browse files
committed
Tests: Use a local cache for many tests importing AppKit
Tests importing AppKit have a tendency to be flaky if they share a module cache with other builds using a different set of framework search flags. Make sure they use a local cache to avoid picking incompatible cached modules. Alternatively, we could align all builds using the same cache to have exactly the same framework search paths or enable explicit module builds. I picked the module cache as it's the most reliable solution in the short and long term. The 5 tests below import AppKit and have been known to be flaky. Adapting them to use a custom cache with require more care. For now, let's use them as control group to validate that the fix works. If these 5 fail without the fixed ones, we should extend the same corresponding fix to them. - Interpreter/SDK/GLKit.swift - Interpreter/SDK/cf_extensions.swift - Interpreter/SDK/cf_type_bridging.swift - Interpreter/SDK/mapkit_header_static.swift - Interpreter/SDK/objc_ns_enum.swift rdar://142296731
1 parent 9d43e7c commit 11c448d

10 files changed

+21
-11
lines changed

test/Interpreter/SDK/Cocoa_transitive.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-build-swift %s
1+
// RUN: %empty-directory(%t/cache)
2+
// RUN: %target-build-swift %s -module-cache-path %t/cache
23
// REQUIRES: executable_test
34

45
// FIXME: iOS does not have Cocoa.framework

test/Interpreter/SDK/GLKit_parse.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-build-swift -typecheck %s -Xfrontend -verify
1+
// RUN: %empty-directory(%t/cache)
2+
// RUN: %target-build-swift -typecheck %s -Xfrontend -verify -module-cache-path %t/cache
23
// REQUIRES: executable_test
34

45
// REQUIRES: objc_interop

test/Interpreter/SDK/NSApplicationMain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-build-swift -typecheck %s
1+
// RUN: %empty-directory(%t/cache)
2+
// RUN: %target-build-swift -typecheck %s -module-cache-path %t/cache
23
// REQUIRES: executable_test
34
// REQUIRES: OS=macosx
45

test/Interpreter/SDK/c_pointers.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift %s -o %t/a.out
2+
// RUN: %empty-directory(%t/cache)
3+
// RUN: %target-build-swift %s -o %t/a.out -module-cache-path %t/cache
34
// RUN: %target-codesign %t/a.out
45
// RUN: %target-run %t/a.out | %FileCheck %s
56
// REQUIRES: executable_test

test/Interpreter/SDK/objc_factory_method.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -module-name FactoryTest %s -o %t/a.out
2+
// RUN: %empty-directory(%t/cache)
3+
// RUN: %target-build-swift -module-name FactoryTest %s -o %t/a.out -module-cache-path %t/cache
34
// RUN: %target-codesign %t/a.out
45
// RUN: %target-run %t/a.out | %FileCheck %s
56
// REQUIRES: executable_test

test/Interpreter/SDK/object_literals.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/cache)
23
// RUN: %empty-directory(%t/Test.app/Contents/MacOS)
34
// RUN: cp -r %S/Inputs/object_literals-Resources %t/Test.app/Contents/Resources
4-
// RUN: %target-build-swift %s -o %t/Test.app/Contents/MacOS/main
5+
// RUN: %target-build-swift %s -o %t/Test.app/Contents/MacOS/main -module-cache-path %t/cache
56
// RUN: %target-codesign %t/Test.app/Contents/MacOS/main
67
// RUN: %target-run %t/Test.app/Contents/MacOS/main %t/Test.app/Contents/Resources/*
78

test/Interpreter/SDK/submodules_smoke_test.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: %target-build-swift -typecheck %s -Xfrontend -verify -Xfrontend -verify-ignore-unknown
2-
// RUN: %target-build-swift -emit-ir -g %s -DNO_ERROR > /dev/null
1+
// RUN: %empty-directory(%t/cache)
2+
// RUN: %target-build-swift -typecheck %s -Xfrontend -verify -Xfrontend -verify-ignore-unknown -module-cache-path %t/cache
3+
// RUN: %target-build-swift -emit-ir -g %s -DNO_ERROR -module-cache-path %t/cache > /dev/null
34
// REQUIRES: executable_test
45

56
// REQUIRES: objc_interop

test/Migrator/remove_override.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// REQUIRES: OS=macosx
22
// RUN: %empty-directory(%t)
3-
// RUN: %target-swift-frontend -c -update-code -swift-version 4 -disable-migrator-fixits -primary-file %s -emit-migrated-file-path %t/remove_override.result.swift -o %t/rename-func-decl.swift.remap %api_diff_data_dir
3+
// RUN: %empty-directory(%t/cache)
4+
// RUN: %target-swift-frontend -c -update-code -swift-version 4 -disable-migrator-fixits -primary-file %s -emit-migrated-file-path %t/remove_override.result.swift -o %t/rename-func-decl.swift.remap %api_diff_data_dir -module-cache-path %t/cache
45
// RUN: diff -u %S/remove_override.swift.expected %t/remove_override.result.swift
56

67
import AppKit

test/Migrator/remove_override.swift.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// REQUIRES: OS=macosx
22
// RUN: %empty-directory(%t)
3-
// RUN: %target-swift-frontend -c -update-code -swift-version 4 -disable-migrator-fixits -primary-file %s -emit-migrated-file-path %t/remove_override.result.swift -o %t/rename-func-decl.swift.remap %api_diff_data_dir
3+
// RUN: %empty-directory(%t/cache)
4+
// RUN: %target-swift-frontend -c -update-code -swift-version 4 -disable-migrator-fixits -primary-file %s -emit-migrated-file-path %t/remove_override.result.swift -o %t/rename-func-decl.swift.remap %api_diff_data_dir -module-cache-path %t/cache
45
// RUN: diff -u %S/remove_override.swift.expected %t/remove_override.result.swift
56

67
import AppKit

test/stdlib/Reflection_objc.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/cache)
23
//
34
// RUN: %target-clang %S/Inputs/Mirror/Mirror.mm -c -o %t/Mirror.mm.o -g
45
// Note: explicitly link the CoreGraphics overlay because does not get autolinked
56
// and it is needed for conformances on macOS < 15.
6-
// RUN: %target-build-swift -parse-stdlib %s -module-name Reflection -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o -o %t/a.out -lswiftCoreGraphics
7+
// RUN: %target-build-swift -parse-stdlib %s -module-name Reflection -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o -o %t/a.out -lswiftCoreGraphics -module-cache-path %t/cache
78
// RUN: %target-codesign %t/a.out
89
// RUN: %target-run %t/a.out %S/Inputs/shuffle.jpg | %FileCheck %s
910

0 commit comments

Comments
 (0)