Skip to content

Commit 07e6b9c

Browse files
authored
Set 'createGitRepo: false' in test fixtures (#4004)
Motivation: Started seeing Git related errors in package collection tests. Modifications: Pass `createGitRepo: false` to `fixture` since the tests don't involve Git repos.
1 parent b4cbd56 commit 07e6b9c

9 files changed

+54
-54
lines changed

Tests/PackageCollectionsSigningTests/CertificatePolicyTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -20,7 +20,7 @@ class CertificatePolicyTests: XCTestCase {
2020
func test_RSA_validate_happyCase() throws {
2121
try skipIfUnsupportedPlatform()
2222

23-
fixture(name: "Collections") { directoryPath in
23+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
2424
let certPath = directoryPath.appending(components: "Signing", "Test_rsa.cer")
2525
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
2626

@@ -40,7 +40,7 @@ class CertificatePolicyTests: XCTestCase {
4040
func test_EC_validate_happyCase() throws {
4141
try skipIfUnsupportedPlatform()
4242

43-
fixture(name: "Collections") { directoryPath in
43+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
4444
let certPath = directoryPath.appending(components: "Signing", "Test_ec.cer")
4545
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
4646

@@ -60,7 +60,7 @@ class CertificatePolicyTests: XCTestCase {
6060
func test_validate_untrustedRoot() throws {
6161
try skipIfUnsupportedPlatform()
6262

63-
fixture(name: "Collections") { directoryPath in
63+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
6464
let certPath = directoryPath.appending(components: "Signing", "Test_rsa.cer")
6565
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
6666

@@ -91,7 +91,7 @@ class CertificatePolicyTests: XCTestCase {
9191
func test_validate_expiredCert() throws {
9292
try skipIfUnsupportedPlatform()
9393

94-
fixture(name: "Collections") { directoryPath in
94+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
9595
let certPath = directoryPath.appending(components: "Signing", "Test_rsa.cer")
9696
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
9797

@@ -121,7 +121,7 @@ class CertificatePolicyTests: XCTestCase {
121121

122122
try skipIfUnsupportedPlatform()
123123

124-
fixture(name: "Collections") { directoryPath in
124+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
125125
let certPath = directoryPath.appending(components: "Signing", "development-revoked.cer")
126126
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
127127

@@ -168,7 +168,7 @@ class CertificatePolicyTests: XCTestCase {
168168

169169
try skipIfUnsupportedPlatform()
170170

171-
fixture(name: "Collections") { directoryPath in
171+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
172172
let certPath = directoryPath.appending(components: "Signing", "development.cer")
173173
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
174174

@@ -236,7 +236,7 @@ class CertificatePolicyTests: XCTestCase {
236236

237237
try skipIfUnsupportedPlatform()
238238

239-
fixture(name: "Collections") { directoryPath in
239+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
240240
// This must be an Apple Swift Package Collection cert
241241
let certPath = directoryPath.appending(components: "Signing", "swift_package_collection.cer")
242242
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
@@ -305,7 +305,7 @@ class CertificatePolicyTests: XCTestCase {
305305

306306
try skipIfUnsupportedPlatform()
307307

308-
fixture(name: "Collections") { directoryPath in
308+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
309309
// This must be an Apple Distribution cert
310310
let certPath = directoryPath.appending(components: "Signing", "development.cer")
311311
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
@@ -374,7 +374,7 @@ class CertificatePolicyTests: XCTestCase {
374374

375375
try skipIfUnsupportedPlatform()
376376

377-
fixture(name: "Collections") { directoryPath in
377+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
378378
let certPath = directoryPath.appending(components: "Signing", "development.cer")
379379
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
380380

@@ -449,7 +449,7 @@ class CertificatePolicyTests: XCTestCase {
449449

450450
try skipIfUnsupportedPlatform()
451451

452-
fixture(name: "Collections") { directoryPath in
452+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
453453
// This must be an Apple Swift Package Collection cert
454454
let certPath = directoryPath.appending(components: "Signing", "swift_package_collection.cer")
455455
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))
@@ -527,7 +527,7 @@ class CertificatePolicyTests: XCTestCase {
527527

528528
try skipIfUnsupportedPlatform()
529529

530-
fixture(name: "Collections") { directoryPath in
530+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
531531
// This must be an Apple Distribution cert
532532
let certPath = directoryPath.appending(components: "Signing", "development.cer")
533533
let certificate = try Certificate(derEncoded: Data(try localFileSystem.readFileContents(certPath).contents))

Tests/PackageCollectionsSigningTests/CertificateTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -19,7 +19,7 @@ class CertificateTests: XCTestCase {
1919
func test_withRSAKey_fromDER() throws {
2020
try skipIfUnsupportedPlatform()
2121

22-
fixture(name: "Collections") { directoryPath in
22+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
2323
let path = directoryPath.appending(components: "Signing", "Test_rsa.cer")
2424
let data = Data(try localFileSystem.readFileContents(path).contents)
2525

@@ -42,7 +42,7 @@ class CertificateTests: XCTestCase {
4242
func test_withECKey_fromDER() throws {
4343
try skipIfUnsupportedPlatform()
4444

45-
fixture(name: "Collections") { directoryPath in
45+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
4646
let path = directoryPath.appending(components: "Signing", "Test_ec.cer")
4747
let data = Data(try localFileSystem.readFileContents(path).contents)
4848

Tests/PackageCollectionsSigningTests/KeyTests+EC.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -19,7 +19,7 @@ class ECKeyTests: XCTestCase {
1919
func testPublicKeyFromCertificate() throws {
2020
try skipIfUnsupportedPlatform()
2121

22-
fixture(name: "Collections") { directoryPath in
22+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
2323
let path = directoryPath.appending(components: "Signing", "Test_ec.cer")
2424
let data = Data(try localFileSystem.readFileContents(path).contents)
2525

Tests/PackageCollectionsSigningTests/KeyTests+RSA.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -19,7 +19,7 @@ class RSAKeyTests: XCTestCase {
1919
func testPublicKeyFromCertificate() throws {
2020
try skipIfUnsupportedPlatform()
2121

22-
fixture(name: "Collections") { directoryPath in
22+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
2323
let path = directoryPath.appending(components: "Signing", "Test_rsa.cer")
2424
let data = Data(try localFileSystem.readFileContents(path).contents)
2525

Tests/PackageCollectionsSigningTests/PackageCollectionSigningTest.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -21,7 +21,7 @@ class PackageCollectionSigningTests: XCTestCase {
2121
func test_RSA_signAndValidate_happyCase() throws {
2222
try skipIfUnsupportedPlatform()
2323

24-
fixture(name: "Collections") { directoryPath in
24+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
2525
let jsonDecoder = JSONDecoder.makeWithDefaults()
2626

2727
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -53,7 +53,7 @@ class PackageCollectionSigningTests: XCTestCase {
5353
func test_RSA_signAndValidate_collectionMismatch() throws {
5454
try skipIfUnsupportedPlatform()
5555

56-
fixture(name: "Collections") { directoryPath in
56+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
5757
let collection1 = PackageCollectionModel.V1.Collection(
5858
name: "Test Package Collection 1",
5959
overview: nil,
@@ -109,7 +109,7 @@ class PackageCollectionSigningTests: XCTestCase {
109109
func test_EC_signAndValidate_happyCase() throws {
110110
try skipIfUnsupportedPlatform()
111111

112-
fixture(name: "Collections") { directoryPath in
112+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
113113
let jsonDecoder = JSONDecoder.makeWithDefaults()
114114

115115
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -141,7 +141,7 @@ class PackageCollectionSigningTests: XCTestCase {
141141
func test_EC_signAndValidate_collectionMismatch() throws {
142142
try skipIfUnsupportedPlatform()
143143

144-
fixture(name: "Collections") { directoryPath in
144+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
145145
let collection1 = PackageCollectionModel.V1.Collection(
146146
name: "Test Package Collection 1",
147147
overview: nil,
@@ -202,7 +202,7 @@ class PackageCollectionSigningTests: XCTestCase {
202202

203203
try skipIfUnsupportedPlatform()
204204

205-
fixture(name: "Collections") { directoryPath in
205+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
206206
let jsonDecoder = JSONDecoder.makeWithDefaults()
207207

208208
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -311,7 +311,7 @@ class PackageCollectionSigningTests: XCTestCase {
311311

312312
try skipIfUnsupportedPlatform()
313313

314-
fixture(name: "Collections") { directoryPath in
314+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
315315
let jsonDecoder = JSONDecoder.makeWithDefaults()
316316

317317
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -405,7 +405,7 @@ class PackageCollectionSigningTests: XCTestCase {
405405

406406
try skipIfUnsupportedPlatform()
407407

408-
fixture(name: "Collections") { directoryPath in
408+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
409409
let jsonDecoder = JSONDecoder.makeWithDefaults()
410410

411411
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -499,7 +499,7 @@ class PackageCollectionSigningTests: XCTestCase {
499499

500500
try skipIfUnsupportedPlatform()
501501

502-
fixture(name: "Collections") { directoryPath in
502+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
503503
let jsonDecoder = JSONDecoder.makeWithDefaults()
504504

505505
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -553,7 +553,7 @@ class PackageCollectionSigningTests: XCTestCase {
553553

554554
try skipIfUnsupportedPlatform()
555555

556-
fixture(name: "Collections") { directoryPath in
556+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
557557
let jsonDecoder = JSONDecoder.makeWithDefaults()
558558

559559
let collectionPath = directoryPath.appending(components: "JSON", "good.json")
@@ -618,7 +618,7 @@ class PackageCollectionSigningTests: XCTestCase {
618618

619619
try skipIfUnsupportedPlatform()
620620

621-
fixture(name: "Collections") { directoryPath in
621+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
622622
let jsonDecoder = JSONDecoder.makeWithDefaults()
623623

624624
let collectionPath = directoryPath.appending(components: "JSON", "good.json")

Tests/PackageCollectionsSigningTests/SignatureTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -19,7 +19,7 @@ class SignatureTests: XCTestCase {
1919
func test_RS256_generateAndValidate_happyCase() throws {
2020
try skipIfUnsupportedPlatform()
2121

22-
fixture(name: "Collections") { directoryPath in
22+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
2323
let jsonEncoder = JSONEncoder()
2424
let jsonDecoder = JSONDecoder()
2525

@@ -45,7 +45,7 @@ class SignatureTests: XCTestCase {
4545
func test_RS256_generateAndValidate_keyMismatch() throws {
4646
try skipIfUnsupportedPlatform()
4747

48-
fixture(name: "Collections") { directoryPath in
48+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
4949
let jsonEncoder = JSONEncoder()
5050
let jsonDecoder = JSONDecoder()
5151

@@ -74,7 +74,7 @@ class SignatureTests: XCTestCase {
7474
func test_ES256_generateAndValidate_happyCase() throws {
7575
try skipIfUnsupportedPlatform()
7676

77-
fixture(name: "Collections") { directoryPath in
77+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
7878
let jsonEncoder = JSONEncoder()
7979
let jsonDecoder = JSONDecoder()
8080

@@ -100,7 +100,7 @@ class SignatureTests: XCTestCase {
100100
func test_ES256_generateAndValidate_keyMismatch() throws {
101101
try skipIfUnsupportedPlatform()
102102

103-
fixture(name: "Collections") { directoryPath in
103+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
104104
let jsonEncoder = JSONEncoder()
105105
let jsonDecoder = JSONDecoder()
106106

Tests/PackageCollectionsTests/GitHubPackageMetadataProviderTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2020-2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2020-2022 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -80,7 +80,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
8080
let apiURL = URL(string: "https://api.github.com/repos/octocat/Hello-World")!
8181
let releasesURL = URL(string: "https://api.github.com/repos/octocat/Hello-World/releases?per_page=20")!
8282

83-
fixture(name: "Collections") { directoryPath in
83+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
8484
let handler: HTTPClient.Handler = { request, _, completion in
8585
switch (request.method, request.url) {
8686
case (.get, apiURL):
@@ -181,7 +181,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
181181
let repoURL = URL(string: "https://github.com/octocat/Hello-World.git")!
182182
let apiURL = URL(string: "https://api.github.com/repos/octocat/Hello-World")!
183183

184-
fixture(name: "Collections") { directoryPath in
184+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
185185
let path = directoryPath.appending(components: "GitHub", "metadata.json")
186186
let data = try Data(localFileSystem.readFileContents(path).contents)
187187
let handler: HTTPClient.Handler = { request, _, completion in
@@ -275,7 +275,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
275275
let total = 5
276276
var remaining = total
277277

278-
fixture(name: "Collections") { directoryPath in
278+
fixture(name: "Collections", createGitRepo: false) { directoryPath in
279279
let path = directoryPath.appending(components: "GitHub", "metadata.json")
280280
let data = try Data(localFileSystem.readFileContents(path).contents)
281281
let handler: HTTPClient.Handler = { request, _, completion in
@@ -320,7 +320,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
320320

321321
func testInvalidURL() throws {
322322
try testWithTemporaryDirectory { tmpPath in
323-
fixture(name: "Collections") { _ in
323+
fixture(name: "Collections", createGitRepo: false) { _ in
324324
var configuration = GitHubPackageMetadataProvider.Configuration()
325325
configuration.cacheDir = tmpPath
326326
let provider = GitHubPackageMetadataProvider(configuration: configuration)
@@ -337,7 +337,7 @@ class GitHubPackageMetadataProviderTests: XCTestCase {
337337

338338
func testInvalidURL2() throws {
339339
try testWithTemporaryDirectory { tmpPath in
340-
fixture(name: "Collections") { _ in
340+
fixture(name: "Collections", createGitRepo: false) { _ in
341341
var configuration = GitHubPackageMetadataProvider.Configuration()
342342
configuration.cacheDir = tmpPath
343343
let provider = GitHubPackageMetadataProvider(configuration: configuration)

0 commit comments

Comments
 (0)