@@ -4847,6 +4847,7 @@ final class WorkspaceTests: XCTestCase {
4847
4847
let sandbox = AbsolutePath ( " /tmp/ws/ " )
4848
4848
let fs = InMemoryFileSystem ( )
4849
4849
var downloads : [ MockDownloader . Download ] = [ ]
4850
+ let hostToolchain = try UserToolchain ( destination: . hostDestination( ) )
4850
4851
4851
4852
let ariFiles = [
4852
4853
"""
@@ -4856,7 +4857,7 @@ final class WorkspaceTests: XCTestCase {
4856
4857
{
4857
4858
" fileName " : " a1.zip " ,
4858
4859
" checksum " : " a1 " ,
4859
- " supportedTriples " : [ " x86_64-apple-macosx " ]
4860
+ " supportedTriples " : [ " \( hostToolchain . triple . tripleString ) " ]
4860
4861
}
4861
4862
]
4862
4863
}
@@ -4868,7 +4869,7 @@ final class WorkspaceTests: XCTestCase {
4868
4869
{
4869
4870
" fileName " : " a2/a2.zip " ,
4870
4871
" checksum " : " a2 " ,
4871
- " supportedTriples " : [ " x86_64-apple-macosx " ]
4872
+ " supportedTriples " : [ " \( hostToolchain . triple . tripleString ) " ]
4872
4873
}
4873
4874
]
4874
4875
}
@@ -5120,6 +5121,7 @@ final class WorkspaceTests: XCTestCase {
5120
5121
func testDownloadArchiveIndexFileBadChecksum( ) throws {
5121
5122
let sandbox = AbsolutePath ( " /tmp/ws/ " )
5122
5123
let fs = InMemoryFileSystem ( )
5124
+ let hostToolchain = try UserToolchain ( destination: . hostDestination( ) )
5123
5125
5124
5126
let ari = """
5125
5127
{
@@ -5128,7 +5130,7 @@ final class WorkspaceTests: XCTestCase {
5128
5130
{
5129
5131
" fileName " : " a1.zip " ,
5130
5132
" checksum " : " a1 " ,
5131
- " supportedTriples " : [ " x86_64-apple-macosx " ]
5133
+ " supportedTriples " : [ " \( hostToolchain . triple . tripleString ) " ]
5132
5134
}
5133
5135
]
5134
5136
}
@@ -5258,6 +5260,7 @@ final class WorkspaceTests: XCTestCase {
5258
5260
func testDownloadArchiveIndexFileBadArchivesChecksum( ) throws {
5259
5261
let sandbox = AbsolutePath ( " /tmp/ws/ " )
5260
5262
let fs = InMemoryFileSystem ( )
5263
+ let hostToolchain = try UserToolchain ( destination: . hostDestination( ) )
5261
5264
5262
5265
let ari = """
5263
5266
{
@@ -5266,7 +5269,7 @@ final class WorkspaceTests: XCTestCase {
5266
5269
{
5267
5270
" fileName " : " a.zip " ,
5268
5271
" checksum " : " a " ,
5269
- " supportedTriples " : [ " x86_64-apple-macosx " ]
5272
+ " supportedTriples " : [ " \( hostToolchain . triple . tripleString ) " ]
5270
5273
}
5271
5274
]
5272
5275
}
@@ -5375,6 +5378,7 @@ final class WorkspaceTests: XCTestCase {
5375
5378
func testDownloadArchiveIndexFileArchiveNotFound( ) throws {
5376
5379
let sandbox = AbsolutePath ( " /tmp/ws/ " )
5377
5380
let fs = InMemoryFileSystem ( )
5381
+ let hostToolchain = try UserToolchain ( destination: . hostDestination( ) )
5378
5382
5379
5383
let ari = """
5380
5384
{
@@ -5383,7 +5387,7 @@ final class WorkspaceTests: XCTestCase {
5383
5387
{
5384
5388
" fileName " : " not-found.zip " ,
5385
5389
" checksum " : " a " ,
5386
- " supportedTriples " : [ " x86_64-apple-macosx " ]
5390
+ " supportedTriples " : [ " \( hostToolchain . triple . tripleString ) " ]
5387
5391
}
5388
5392
]
5389
5393
}
@@ -5451,6 +5455,83 @@ final class WorkspaceTests: XCTestCase {
5451
5455
}
5452
5456
}
5453
5457
5458
+ func testDownloadArchiveIndexTripleNotFound( ) throws {
5459
+ let sandbox = AbsolutePath ( " /tmp/ws/ " )
5460
+ let fs = InMemoryFileSystem ( )
5461
+
5462
+ let hostToolchain = try UserToolchain ( destination: . hostDestination( ) )
5463
+ let andriodTriple = try Triple ( " x86_64-unknown-linux-android " )
5464
+ let notHostTriple = hostToolchain. triple == andriodTriple ? . macOS : andriodTriple
5465
+
5466
+ let ari = """
5467
+ {
5468
+ " schemaVersion " : " 1.0 " ,
5469
+ " archives " : [
5470
+ {
5471
+ " fileName " : " a1.zip " ,
5472
+ " checksum " : " a1 " ,
5473
+ " supportedTriples " : [ " \( notHostTriple. tripleString) " ]
5474
+ }
5475
+ ]
5476
+ }
5477
+ """
5478
+ let checksumAlgorithm = MockHashAlgorithm ( ) // used in tests
5479
+ let ariChecksum = checksumAlgorithm. hash ( ari) . hexadecimalRepresentation
5480
+
5481
+ // returns a dummy ari files for the requested artifact
5482
+ let httpClient = HTTPClient ( handler: { request, _, completion in
5483
+ do {
5484
+ let contents : String
5485
+ switch request. url. lastPathComponent {
5486
+ case " a.ari " :
5487
+ contents = ari
5488
+ default :
5489
+ throw StringError ( " unexpected url \( request. url) " )
5490
+ }
5491
+ completion ( . success( . init( statusCode: 200 , body: Data ( contents. utf8) ) ) )
5492
+ } catch {
5493
+ completion ( . failure( DownloaderError . clientError ( error) ) )
5494
+ }
5495
+ } )
5496
+
5497
+ let workspace = try MockWorkspace (
5498
+ sandbox: sandbox,
5499
+ fs: fs,
5500
+ httpClient: httpClient,
5501
+ roots: [
5502
+ MockPackage (
5503
+ name: " Foo " ,
5504
+ targets: [
5505
+ MockTarget ( name: " Foo " , dependencies: [ " A " ] ) ,
5506
+ ] ,
5507
+ products: [ ] ,
5508
+ dependencies: [
5509
+ . git( name: " A " , requirement: . exact( " 1.0.0 " ) ) ,
5510
+ ]
5511
+ ) ,
5512
+ ] ,
5513
+ packages: [
5514
+ MockPackage (
5515
+ name: " A " ,
5516
+ targets: [
5517
+ MockTarget ( name: " A " , type: . binary, url: " https://a.com/a.ari " , checksum: ariChecksum) ,
5518
+ ] ,
5519
+ products: [
5520
+ MockProduct ( name: " A " , targets: [ " A " ] ) ,
5521
+ ] ,
5522
+ versions: [ " 0.9.0 " , " 1.0.0 " ]
5523
+ ) ,
5524
+ ]
5525
+ )
5526
+
5527
+ workspace. checkPackageGraphFailure ( roots: [ " Foo " ] ) { diagnostics in
5528
+ XCTAssertEqual ( workspace. downloader. downloads, [ ] )
5529
+ DiagnosticsEngineTester ( diagnostics) { result in
5530
+ result. check ( diagnostic: . contains( " failed retrieving 'https://a.com/a.ari': No supported archive was found for ' \( hostToolchain. triple. tripleString) ' " ) , behavior: . error)
5531
+ }
5532
+ }
5533
+ }
5534
+
5454
5535
func testAndroidCompilerFlags( ) throws {
5455
5536
let target = try Triple ( " x86_64-unknown-linux-android " )
5456
5537
let sdk = AbsolutePath ( " /some/path/to/an/SDK.sdk " )
0 commit comments