Skip to content

Commit d77c387

Browse files
authored
[5.9][ScanDependencies] Fix JSON generation under certain circunstances. (#67265)
The code of `ScanDependencies.cpp` was creating invalid JSON since #66031 because in the case of having `extraPcmArgs` and `swiftOverlayDependencies`, but not `bridgingHeader`, a comma will not be added at the end of `extraPcmArgs`, creating an invalid JSON file. Additionally that same PR added a trailing comma at the end of the `swiftOverlayDependencies`, which valid JSON does not allow, but that bug was removed in #66366. Both problems are, however, present in the 5.9 branch, because #66936 included #66031, but not #66366. Besides fixing the problem in `ScanDependencies.cpp` I modified every test that uses `--scan-dependencies` to pass the produced JSON through Python's `json.tool` in order to validate proper JSON is produced. In most cases I was able to pipe the output of the tool into `FileCheck`, but in some cases the validation is done by itself because the checks depend on the exact format generated by `--scan-dependencies`. In a couple of tests I added a call to `FileCheck` that seemed to be missing. Without these changes, two tests seems to be generating invalid JSON in my machine: - `ScanDependencies/local_cache_consistency.swift` (which outputs `Expecting ',' delimiter: line 525 column 11 (char 22799)`) - `ScanDependencies/placholder_overlay_deps.swift` Additional changes for the cherry-pick: - Removed some changes in some CAS tests that are not present in release/5.9. - Switch `trailingComma` from `true` to `false` for `swiftOverlayDependencies` similar to what #66366 did in `main`. - Remove the new `RUN` line in `optional_deps_of_testable_imports.swift` because it fails in 5.9 if the `CHECK` is performed. (cherry picked from commit 7de1089)
1 parent 5550394 commit d77c387

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+70
-56
lines changed

lib/DependencyScan/ScanDependencies.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,11 @@ static void writeJSON(llvm::raw_ostream &out,
852852
bool hasOverlayDependencies =
853853
swiftTextualDeps->swift_overlay_module_dependencies &&
854854
swiftTextualDeps->swift_overlay_module_dependencies->count > 0;
855+
bool commaAfterBridgingHeaderPath = hasOverlayDependencies;
856+
bool commaAfterExtraPcmArgs =
857+
hasBridgingHeaderPath || commaAfterBridgingHeaderPath;
855858
bool commaAfterFramework =
856-
swiftTextualDeps->extra_pcm_args->count != 0 || hasBridgingHeaderPath;
859+
swiftTextualDeps->extra_pcm_args->count != 0 || commaAfterExtraPcmArgs;
857860

858861
writeJSONSingleField(out, "isFramework", swiftTextualDeps->is_framework,
859862
5, commaAfterFramework);
@@ -871,7 +874,7 @@ static void writeJSON(llvm::raw_ostream &out,
871874
out << "\n";
872875
}
873876
out.indent(5 * 2);
874-
out << (hasBridgingHeaderPath ? "],\n" : "]\n");
877+
out << (commaAfterExtraPcmArgs ? "],\n" : "]\n");
875878
}
876879
/// Bridging header and its source file dependencies, if any.
877880
if (hasBridgingHeaderPath) {
@@ -887,12 +890,12 @@ static void writeJSON(llvm::raw_ostream &out,
887890
swiftTextualDeps->bridging_module_dependencies, 6,
888891
/*trailingComma=*/false);
889892
out.indent(5 * 2);
890-
out << (hasOverlayDependencies ? "},\n" : "}\n");
893+
out << (commaAfterBridgingHeaderPath ? "},\n" : "}\n");
891894
}
892895
if (hasOverlayDependencies) {
893896
writeDependencies(out, swiftTextualDeps->swift_overlay_module_dependencies,
894897
"swiftOverlayDependencies", 5,
895-
/*trailingComma=*/true);
898+
/*trailingComma=*/false);
896899
}
897900
} else if (swiftPlaceholderDeps) {
898901
out << "\"swiftPlaceholder\": {\n";

test/Frontend/module-alias-scan-deps.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/// Scanned dependencies should contain real name AppleLogging
1414
// RUN: %target-swift-frontend -scan-dependencies %t/FileLib.swift -module-alias XLogging=AppleLogging -I %t > %t/scandump.output
15-
// RUN: %FileCheck %s -check-prefix=CHECK-REAL-NAME -input-file %t/scandump.output
15+
// RUN: %validate-json %t/scandump.output | %FileCheck %s -check-prefix=CHECK-REAL-NAME
1616
// CHECK-REAL-NAME-NOT: "swiftPrebuiltExternal": "XLogging"
1717
// CHECK-REAL-NAME-NOT: "compiledModulePath":{{.*}}XLogging.swiftmodule",
1818
// CHECK-REAL-NAME: "swiftPrebuiltExternal": "AppleLogging"
@@ -25,7 +25,7 @@
2525

2626
/// Scanned dependencies should contain real name AppleLoggingIF
2727
// RUN: %target-swift-frontend -scan-dependencies %t/FileLib.swift -module-alias XLogging=AppleLoggingIF -I %t > %t/scandumpIF.output
28-
// RUN: %FileCheck %s -check-prefix=CHECK-REAL-NAME-IF -input-file %t/scandumpIF.output
28+
// RUN: %validate-json %t/scandumpIF.output | %FileCheck %s -check-prefix=CHECK-REAL-NAME-IF
2929
// CHECK-REAL-NAME-IF-NOT: "swift": "XLogging"
3030
// CHECK-REAL-NAME-IF-NOT: "moduleInterfacePath":{{.*}}XLogging.swiftinterface
3131
// CHECK-REAL-NAME-IF: "swift": "AppleLoggingIF"

test/ModuleInterface/clang-args-transitive-availability.swift

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: %target-swift-frontend -typecheck -strict-implicit-module-context %s -I %S/Inputs/macro-only-module -Xcc -DTANGERINE=1 -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
77

88
// RUN: %target-swift-frontend -scan-dependencies -strict-implicit-module-context %s -o %t/deps.json -I %S/Inputs/macro-only-module -Xcc -DTANGERINE=1 -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
9+
// RUN: %validate-json %t/deps.json &>/dev/null
910
// RUN: %FileCheck %s < %t/deps.json
1011

1112
import ImportsMacroSpecificClangModule

test/ModuleInterface/clang-session-transitive.swift

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// RUN: %target-build-swift -module-name TestModule -module-link-name TestModule %S/Inputs/TestModule.swift -enable-library-evolution -emit-module-interface -o %t/TestModule.swiftmodule -swift-version 5 -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import
66

77
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I%t -validate-clang-modules-once -clang-build-session-file %t/Build.session -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
8+
// RUN: %validate-json %t/deps.json &>/dev/null
89
// RUN: %FileCheck %s < %t/deps.json
910

1011
import TestModule

test/ModuleInterface/extension-transitive-availability.swift

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-swift-emit-module-interface(%t/ExtensionAvailable.swiftinterface) %S/Inputs/extension-available.swift -module-name ExtensionAvailable -I%t -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
55

66
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I%t -application-extension -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
7+
// RUN: %validate-json %t/deps.json &>/dev/null
78
// RUN: %FileCheck %s < %t/deps.json
89

910
import ExtensionAvailable

test/ModuleInterface/infer-arch-from-file.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
import arm64
77

88
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t -target arm64-apple-macos11.0
9-
// RUN: %FileCheck %s < %t/deps.json
9+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1010

1111
// CHECK-NOT: arm64e-apple-macos11.0

test/ScanDependencies/batch_module_scan.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -batch-scan-input-file %/t/inputs/input.json
1818

1919
// Check the contents of the JSON output
20-
// RUN: %FileCheck %s -check-prefix=CHECK-PCM < %t/outputs/F.pcm.json
21-
// RUN: %FileCheck %s -check-prefix=CHECK-SWIFT < %t/outputs/F.swiftmodule.json
20+
// RUN: %validate-json %t/outputs/F.pcm.json | %FileCheck %s -check-prefix=CHECK-PCM
21+
// RUN: %validate-json %t/outputs/F.swiftmodule.json | %FileCheck %s -check-prefix=CHECK-SWIFT
2222

2323
// CHECK-PCM: {
2424
// CHECK-PCM-NEXT: "mainModuleName": "F",

test/ScanDependencies/batch_module_scan_arguments.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -batch-scan-input-file %/t/inputs/input.json
1818

1919
// Check the contents of the JSON output
20-
// RUN: %FileCheck %s -check-prefix=CHECK-TEN < %t/outputs/H.10.9.pcm.json
21-
// RUN: %FileCheck %s -check-prefix=CHECK-ELEVEN < %t/outputs/H.11.0.pcm.json
20+
// RUN: %validate-json %t/outputs/H.10.9.pcm.json | %FileCheck %s -check-prefix=CHECK-TEN
21+
// RUN: %validate-json %t/outputs/H.11.0.pcm.json | %FileCheck %s -check-prefix=CHECK-ELEVEN
2222

2323
// CHECK-TEN: "clang": "I"
2424
// CHECK-ELEVEN-NOT: "clang": "I"

test/ScanDependencies/batch_module_scan_versioned.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
// RUN: %target-swift-frontend -scan-dependencies -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -target %target-cpu-apple-macosx11.0 -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -batch-scan-input-file %/t/inputs/input.json
1818

1919
// Check the contents of the JSON output
20-
// RUN: %FileCheck %s -check-prefix=CHECK-PCM109 < %t/outputs/G_109.pcm.json
20+
// RUN: %validate-json %t/outputs/G_109.pcm.json | %FileCheck %s -check-prefix=CHECK-PCM109
21+
// RUN: %validate-json %t/outputs/G_110.pcm.json &>/dev/null
2122
// RUN: %FileCheck %s -check-prefix=CHECK-PCM110 < %t/outputs/G_110.pcm.json
2223

2324
// CHECK-PCM109: {

test/ScanDependencies/batch_prescan.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// RUN: %target-swift-frontend -scan-dependencies -import-prescan -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -batch-scan-input-file %/t/inputs/input.json
1313

1414
// Check the contents of the JSON output
15-
// RUN: %FileCheck %s -check-prefix=CHECK-SWIFT < %t/outputs/F.swiftmodule.json
15+
// RUN: %validate-json %t/outputs/F.swiftmodule.json | %FileCheck %s -check-prefix=CHECK-SWIFT
1616

1717
// CHECK-SWIFT: {
1818
// CHECK-SWIFT-NEXT:"imports": [

test/ScanDependencies/bin_mod_import.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import EWrapper
88
// RUN: %target-swift-frontend -compile-module-from-interface %S/Inputs/Swift/EWrapper.swiftinterface -o %t/EWrapper.swiftmodule -I %t
99
// Step 3: scan dependency should give us the binary module and a textual swift dependency from it
1010
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t
11-
// RUN: %FileCheck %s < %t/deps.json
11+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1212

1313
// Step 4: Ensure that round-trip serialization does not affect result
1414
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization %s -o %t/deps.json -I %t
15-
// RUN: %FileCheck %s < %t/deps.json
15+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1616

1717
// CHECK: "modulePath": "{{.*}}EWrapper.swiftmodule"
1818
// CHECK-NEXT: "directDependencies": [

test/ScanDependencies/binary_framework_dependency.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// Run the scan
1313
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -F %t/Frameworks/ -sdk %t
14-
// RUN: %FileCheck %s < %t/deps.json
14+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1515

1616
import Foo
1717

test/ScanDependencies/binary_module_only.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import Foo
2222

2323
// Step 3: scan dependencies, pointed only at the binary module file should detect it as a swiftBinaryModule kind of dependency
2424
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t/binaryModuleOnly -emit-dependencies -emit-dependencies-path %t/deps.d -sdk %t -prebuilt-module-cache-path %t/ResourceDir/%target-sdk-name/prebuilt-modules
25-
// RUN: %FileCheck %s -check-prefix=BINARY_MODULE_ONLY < %t/deps.json
25+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix=BINARY_MODULE_ONLY
2626

2727
// Step 4: Ensure that round-trip serialization does not affect result
2828
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization %s -o %t/deps.json -I %t/binaryModuleOnly -emit-dependencies -emit-dependencies-path %t/deps.d -sdk %t -prebuilt-module-cache-path %t/ResourceDir/%target-sdk-name/prebuilt-modules
29-
// RUN: %FileCheck %s -check-prefix=BINARY_MODULE_ONLY < %t/deps.json
29+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix=BINARY_MODULE_ONLY

test/ScanDependencies/blocklist-path-pass-down.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// Run the scan
1717
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -F %t/Frameworks/ -sdk %t -blocklist-file %t/blocklist.yml
18-
// RUN: %FileCheck %s < %t/deps.json
18+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1919

2020
import E
2121

test/ScanDependencies/can_import_placeholder.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// RUN: echo "}]" >> %/t/inputs/map.json
1212

1313
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
14-
// RUN: %FileCheck %s < %t/deps.json
14+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1515

1616
// Ensure that round-trip serialization does not affect result
1717
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
18-
// RUN: %FileCheck %s < %t/deps.json
18+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1919

2020
// REQUIRES: executable_test
2121
// REQUIRES: objc_interop

test/ScanDependencies/clang-target.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// RUN: find %t.module-cache -name "X-*.pcm" | count 1
1515
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache %s -o %t.deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -target %target-cpu-apple-macosx10.14 -clang-target %target-cpu-apple-macosx10.14
1616

17-
// RUN: %FileCheck %s < %t.deps.json
17+
// RUN: %validate-json %t.deps.json | %FileCheck %s
1818

1919
// CHECK: "-clang-target"
2020
// CHECK-NEXT: "{{.*}}-apple-macosx10.14"

test/ScanDependencies/compiled_swift_modules.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ import Foo
1515

1616
// Step 2: scan dependency should give us the binary module adjacent to the interface file.
1717
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t -emit-dependencies -emit-dependencies-path %t/deps.d
18-
// RUN: %FileCheck %s -check-prefix=HAS_COMPILED < %t/deps.json
18+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix=HAS_COMPILED
1919

2020
// Step 3: remove the adjacent module.
2121
// RUN: rm %t/Foo.swiftmodule/%target-swiftmodule-name
2222

2323
// Step 4: scan dependency should give us the interface file.
2424
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t -emit-dependencies -emit-dependencies-path %t/deps.d
25-
// RUN: %FileCheck %s -check-prefix=HAS_NO_COMPILED < %t/deps.json
25+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix=HAS_NO_COMPILED
2626

2727
// Step 4: build prebuilt module cache using the interface.
2828
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/ResourceDir/%target-sdk-name/prebuilt-modules/Foo.swiftmodule/%target-swiftmodule-name -module-name Foo -disable-interface-lock %t/Foo.swiftmodule/%target-swiftinterface-name
2929

3030
// Step 5: scan dependency now should give us the prebuilt module cache
3131
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t -emit-dependencies -emit-dependencies-path %t/deps.d -sdk %t -prebuilt-module-cache-path %t/ResourceDir/%target-sdk-name/prebuilt-modules
32-
// RUN: %FileCheck %s -check-prefix=HAS_COMPILED < %t/deps.json
32+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix=HAS_COMPILED
3333

3434
// Step 6: update the interface file from where the prebuilt module cache was built.
3535
// RUN: touch %t/Foo.swiftmodule/%target-swiftinterface-name
3636

3737
// Step 7: scan dependency should give us the prebuilt module file even though it's out-of-date.
3838
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t -emit-dependencies -emit-dependencies-path %t/deps.d -sdk %t -prebuilt-module-cache-path %t/ResourceDir/%target-sdk-name/prebuilt-modules
39-
// RUN: %FileCheck %s -check-prefix=HAS_COMPILED < %t/deps.json
39+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix=HAS_COMPILED

test/ScanDependencies/embed_tbd_module_dependency.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: mkdir -p %t/clang-module-cache
33

44
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -swift-version 4 -embed-tbd-for-module E
5-
// RUN: %FileCheck %s < %t/deps.json
5+
// RUN: %validate-json %t/deps.json | %FileCheck %s
66

77
// CHECK: "mainModuleName": "deps"
88
// CHECK-NEXT: "modules": [

test/ScanDependencies/escaped.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -scan-dependencies %s -I %S\\Inputs -o - | %FileCheck %s
2+
// RUN: %target-swift-frontend -scan-dependencies %s -I %S\\Inputs -o - | %validate-json | %FileCheck %s
33

44
// We want to explicitly use the Windows path separator
55
// REQUIRES: OS=windows-msvc

test/ScanDependencies/explicit-swift-dependencies.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
55
// Check the contents of the JSON output
6-
// RUN: %FileCheck %s < %t/deps.json
6+
// RUN: %validate-json %t/deps.json | %FileCheck %s
77

88
// REQUIRES: executable_test
99
// REQUIRES: objc_interop

test/ScanDependencies/include-sdk-in-command.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -sdk %t/mysecretsdk.sdk
44

55
// Check the contents of the JSON output
6-
// RUN: %FileCheck %s < %t/deps.json
6+
// RUN: %validate-json %t/deps.json | %FileCheck %s
77

88
func foo() { print(1) }
99

test/ScanDependencies/local_cache_consistency.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// Run the scanner once, ensuring CoreFoundation dependencies are as expected
99
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -swift-version 4
10-
// RUN: %FileCheck %s < %t/deps.json
10+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1111

1212
import CoreFoundation
1313

test/ScanDependencies/module_deps.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
55
// Check the contents of the JSON output
6-
// RUN: %FileCheck -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
6+
// RUN: %validate-json %t/deps.json | %FileCheck -check-prefix CHECK_NO_CLANG_TARGET %s
77

88
// Check the contents of the JSON output
9-
// RUN: %FileCheck %s -check-prefix CHECK-NO-SEARCH-PATHS < %t/deps.json
9+
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix CHECK-NO-SEARCH-PATHS
1010

1111
// Check the make-style dependencies file
1212
// RUN: %FileCheck %s -check-prefix CHECK-MAKE-DEPS < %t/deps.d
@@ -22,12 +22,12 @@
2222

2323
// Ensure that round-trip serialization does not affect result
2424
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
25-
// RUN: %FileCheck -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
25+
// RUN: %validate-json %t/deps.json | %FileCheck -check-prefix CHECK_NO_CLANG_TARGET %s
2626

2727
// Ensure that scanning with `-clang-target` makes sure that Swift modules' respective PCM-dependency-build-argument sets do not contain target triples.
2828
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps_clang_target.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -clang-target %target-cpu-apple-macosx10.14
2929
// Check the contents of the JSON output
30-
// RUN: %FileCheck -check-prefix CHECK_CLANG_TARGET %s < %t/deps_clang_target.json
30+
// RUN: %validate-json %t/deps_clang_target.json | %FileCheck -check-prefix CHECK_CLANG_TARGET %s
3131

3232
// REQUIRES: executable_test
3333
// REQUIRES: objc_interop

test/ScanDependencies/module_deps_cache_reuse.swift

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// RUN: %target-swift-frontend -scan-dependencies -Rdependency-scan-cache -load-dependency-scan-cache -dependency-scan-cache-path %t/cache.moddepcache -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 2>&1 | %FileCheck %s -check-prefix CHECK-REMARK-LOAD
99

1010
// Check the contents of the JSON output
11+
// RUN: %validate-json %t/deps.json &>/dev/null
1112
// RUN: %FileCheck %s < %t/deps.json
1213

1314
// REQUIRES: executable_test
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t.module-cache)
22
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache %s -o %t.deps.json -I %S/Inputs/CHeaders
33

4-
// RUN: %FileCheck %s < %t.deps.json
4+
// RUN: %validate-json %t.deps.json | %FileCheck %s
55
// CHECK: "clang": "X_Private"
66
import X.Private
77

test/ScanDependencies/module_deps_cross_import_overlay.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// RUN: mkdir -p %t/clang-module-cache
33
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
44
// Check the contents of the JSON output
5-
// RUN: %FileCheck %s < %t/deps.json
5+
// RUN: %validate-json %t/deps.json | %FileCheck %s
66

77
// Ensure that round-trip serialization does not affect result
88
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
9-
// RUN: %FileCheck %s < %t/deps.json
9+
// RUN: %validate-json %t/deps.json | %FileCheck %s
1010

1111
// REQUIRES: executable_test
1212
// REQUIRES: objc_interop

0 commit comments

Comments
 (0)