-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2588 from hartbit/binary-targets-tests
Reimplement binary targets tests without binaries
- Loading branch information
Showing
21 changed files
with
338 additions
and
28 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
IntegrationTests/Fixtures/BinaryTargets/Inputs/DynamicLibrary/DynamicLibrary.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
#import "DynamicLibrary.h" | ||
|
||
@implementation DynamicLibrary | ||
@end |
14 changes: 14 additions & 0 deletions
14
IntegrationTests/Fixtures/BinaryTargets/Inputs/DynamicLibrary/include/DynamicLibrary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface DynamicLibrary : NSObject | ||
@end |
14 changes: 14 additions & 0 deletions
14
IntegrationTests/Fixtures/BinaryTargets/Inputs/StaticLibrary/StaticLibrary.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
#import "StaticLibrary.h" | ||
|
||
@implementation StaticLibrary | ||
@end |
14 changes: 14 additions & 0 deletions
14
IntegrationTests/Fixtures/BinaryTargets/Inputs/StaticLibrary/include/StaticLibrary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface StaticLibrary : NSObject | ||
@end |
24 changes: 24 additions & 0 deletions
24
IntegrationTests/Fixtures/BinaryTargets/Inputs/SwiftFramework/SwiftFramework/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2020 David Hart. All rights reserved.</string> | ||
</dict> | ||
</plist> |
19 changes: 19 additions & 0 deletions
19
...grationTests/Fixtures/BinaryTargets/Inputs/SwiftFramework/SwiftFramework/SwiftFramework.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// SwiftFramework.h | ||
// SwiftFramework | ||
// | ||
// Created by David Hart on 17.02.20. | ||
// Copyright © 2020 David Hart. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
//! Project version number for SwiftFramework. | ||
FOUNDATION_EXPORT double SwiftFrameworkVersionNumber; | ||
|
||
//! Project version string for SwiftFramework. | ||
FOUNDATION_EXPORT const unsigned char SwiftFrameworkVersionString[]; | ||
|
||
// In this header, you should import all the public headers of your framework using statements like #import <SwiftFramework/PublicHeader.h> | ||
|
||
|
13 changes: 13 additions & 0 deletions
13
...ionTests/Fixtures/BinaryTargets/Inputs/SwiftFramework/SwiftFramework/SwiftFramework.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// SwiftFramework.swift | ||
// SwiftFramework | ||
// | ||
// Created by David Hart on 17.02.20. | ||
// Copyright © 2020 David Hart. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct SwiftFramework { | ||
public init() {} | ||
} |
18 changes: 18 additions & 0 deletions
18
IntegrationTests/Fixtures/BinaryTargets/TestBinary/Package.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// swift-tools-version:999.0 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "TestBinary", | ||
dependencies: [ | ||
], | ||
targets: [ | ||
.target(name: "exe", dependencies: ["Library"]), | ||
.target(name: "Library", dependencies: ["SwiftFramework"]), | ||
.target(name: "cexe", dependencies: ["CLibrary"]), | ||
.target(name: "CLibrary", dependencies: ["StaticLibrary", "DynamicLibrary"]), | ||
.binaryTarget(name: "SwiftFramework", path: "SwiftFramework.xcframework"), | ||
.binaryTarget(name: "StaticLibrary", path: "StaticLibrary.xcframework"), | ||
.binaryTarget(name: "DynamicLibrary", path: "DynamicLibrary.xcframework"), | ||
] | ||
) |
12 changes: 12 additions & 0 deletions
12
IntegrationTests/Fixtures/BinaryTargets/TestBinary/Sources/CLibrary/CLibrary.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import "CLibrary.h" | ||
|
||
@implementation CLibrary | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
_staticLibrary = [StaticLibrary new]; | ||
_dynamicLibrary = [DynamicLibrary new]; | ||
return self; | ||
} | ||
|
||
@end |
9 changes: 9 additions & 0 deletions
9
IntegrationTests/Fixtures/BinaryTargets/TestBinary/Sources/CLibrary/include/CLibrary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import <StaticLibrary.h> | ||
#import <DynamicLibrary.h> | ||
|
||
@interface CLibrary: NSObject | ||
|
||
@property (nonatomic, readonly) StaticLibrary* staticLibrary; | ||
@property (nonatomic, readonly) DynamicLibrary* dynamicLibrary; | ||
|
||
@end |
8 changes: 8 additions & 0 deletions
8
IntegrationTests/Fixtures/BinaryTargets/TestBinary/Sources/Library/Library.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import SwiftFramework | ||
|
||
public struct Library { | ||
public let framework = SwiftFramework() | ||
|
||
public init() { | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
IntegrationTests/Fixtures/BinaryTargets/TestBinary/Sources/cexe/main.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import <CLibrary.h> | ||
|
||
int main(int argc, const char* argv[]) { | ||
printf("%s", [CLibrary new].description.UTF8String); | ||
} |
5 changes: 5 additions & 0 deletions
5
IntegrationTests/Fixtures/BinaryTargets/TestBinary/Sources/exe/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import SwiftFramework | ||
import Library | ||
|
||
print(SwiftFramework()) | ||
print(Library()) |
Binary file added
BIN
+37.2 KB
IntegrationTests/Fixtures/BinaryTargets/TestBinary/SwiftFramework.zip
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions
13
IntegrationTests/Fixtures/XCBuild/SystemTargets/Inputs/libsys.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
const char* GetSystemLibName() { | ||
return "SystemLibrary"; | ||
} |
12 changes: 11 additions & 1 deletion
12
IntegrationTests/Fixtures/XCBuild/SystemTargets/Inputs/libsys.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
const char* GetSystemLibName(); | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
const char* GetSystemLibName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import XCTest | ||
import TSCBasic | ||
import TSCTestSupport | ||
|
||
final class SwiftPMTests: XCTestCase { | ||
#if os(macOS) | ||
func testBinaryTargets() throws { | ||
try binaryTargetsFixture { prefix in | ||
do { | ||
let (stdout, stderr) = try sh(swiftRun, "--package-path", prefix, "exe") | ||
XCTAssertNoMatch(stderr, .contains("warning: ")) | ||
XCTAssertEqual(stdout, """ | ||
SwiftFramework() | ||
Library(framework: SwiftFramework.SwiftFramework()) | ||
""") | ||
} | ||
|
||
do { | ||
let (stdout, stderr) = try sh(swiftRun, "--package-path", prefix, "cexe") | ||
XCTAssertNoMatch(stderr, .contains("warning: ")) | ||
XCTAssertMatch(stdout, .contains("<CLibrary: ")) | ||
} | ||
|
||
do { | ||
let invalidPath = prefix.appending(component: "SwiftFramework.xcframework") | ||
let (_, stderr) = try shFails(swiftPackage, "--package-path", prefix, "compute-checksum", invalidPath) | ||
XCTAssertMatch(stderr, .contains("error: unexpected file type; supported extensions are: zip")) | ||
|
||
let validPath = prefix.appending(component: "SwiftFramework.zip") | ||
let (stdout, _) = try sh(swiftPackage, "--package-path", prefix, "compute-checksum", validPath) | ||
XCTAssertEqual(stdout.spm_chomp(), "d1f202b1bfe04dea30b2bc4038f8059dcd75a5a176f1d81fcaedb6d3597d1158") | ||
} | ||
} | ||
} | ||
#endif | ||
} |
Oops, something went wrong.