Permalink
Browse files

Testing Support

We now build `swift-test`, which will create a test runner based on the layout of your Test modules as per our testing proposal:

https://github.com/apple/swift-evolution/blob/master/proposals/0019-package-manager-testing.md

Also includes a significant refactor. I am sorry this is not more atomic, but the work just kept expanding in scope and keeping history straight was too much work.

Notable improvements aside from the testing propopsal:

 * Whole Module Optimization is applied to release builds
 * A single llbuild.yaml file is created for all packages in a project, this allows llbuild to properly manage build dependencies
 * A new products feature has been added to Package.swift which allows you to define product targets (like dynamic libraries) that consist of a series of modules

The refactor involved creating many more modules with much more refined and defined scope and responsibility. The code is now much more maintainable.
  • Loading branch information...
mxcl committed Feb 9, 2016
1 parent f7f0d74 commit ae9121960e977066ee93c985602bb64df60db770
Showing with 3,226 additions and 3,693 deletions.
  1. +10 −0 Fixtures/DependencyResolution/External/Complex/app/Package.swift
  2. +10 −0 Fixtures/DependencyResolution/External/Complex/app/main.swift
  3. +10 −0 Fixtures/DependencyResolution/External/Complex/deck-of-playing-cards/src/Deck.swift
  4. 0 Tests/sys/Inputs/empty_file → Fixtures/Miscellaneous/Empty/Package.swift
  5. +5 −0 Fixtures/Miscellaneous/ExactDependencies/FooLib1/Package.swift
  6. +3 −0 Fixtures/Miscellaneous/ExactDependencies/FooLib1/Sources/cli/main.swift
  7. +41 −10 Package.swift
  8. +1 −3 README.md
  9. +10 −1 Sources/{POSIX/exit.swift → Build/Configuration.swift}
  10. +41 −0 Sources/Build/IncrementalNode.swift
  11. +63 −0 Sources/Build/YAML.swift
  12. +182 −0 Sources/Build/describe().swift
  13. +123 −0 Sources/Build/misc.swift
  14. +16 −4 Sources/{dep → Get}/Error.swift
  15. +30 −0 Sources/Get/Fetchable.swift
  16. +102 −0 Sources/Get/Fetcher.swift
  17. +62 −0 Sources/Get/Git.swift
  18. +52 −0 Sources/Get/Package.swift
  19. +67 −0 Sources/Get/PackagesDirectory.swift
  20. +8 −0 Sources/Get/README.md
  21. +27 −0 Sources/Get/Range.swift
  22. +106 −0 Sources/Get/RawClone.swift
  23. +34 −0 Sources/Get/Version.swift
  24. +44 −0 Sources/Get/get().swift
  25. +32 −0 Sources/ManifestParser/Error.swift
  26. +75 −0 Sources/ManifestParser/Manifest+parse.swift
  27. +0 −2 Sources/{sys → ManifestParser}/TOML.swift
  28. +36 −68 Sources/{dep/Manifest.swift → ManifestParser/fromTOML().swift}
  29. +74 −0 Sources/Multitool/Error.swift
  30. +17 −0 Sources/Multitool/build().swift
  31. +31 −0 Sources/Multitool/directories.swift
  32. +2 −18 Sources/POSIX/fopen.swift
  33. +1 −0 Sources/POSIX/fputs.swift
  34. +1 −3 Sources/POSIX/readlink.swift
  35. +1 −2 Sources/POSIX/realpath.swift
  36. +4 −4 Sources/POSIX/system.swift
  37. +5 −6 Sources/PackageDescription/Package.swift
  38. +67 −0 Sources/PackageDescription/Product.swift
  39. +7 −1 Sources/{POSIX/FILE.swift → PackageDescription/TOMLConvertible.swift}
  40. +65 −0 Sources/PackageDescription/Version+StringLiteralConvertible.swift
  41. +2 −289 Sources/PackageDescription/Version.swift
  42. +37 −0 Sources/PackageType/Manifest.swift
  43. +4 −2 Sources/{dep/moduleNameForName.swift → PackageType/Module+c99name.swift}
  44. +107 −0 Sources/PackageType/Module.swift
  45. +60 −0 Sources/PackageType/Package.swift
  46. +61 −0 Sources/PackageType/Product.swift
  47. +29 −0 Sources/PackageType/Sources.swift
  48. +30 −0 Sources/Transmute/Error.swift
  49. +94 −0 Sources/Transmute/Package+modules.swift
  50. +51 −0 Sources/Transmute/Package+products.swift
  51. +34 −0 Sources/Transmute/Package+shouldConsiderDirectory.swift
  52. +36 −0 Sources/Transmute/Package+sourceRoot.swift
  53. +20 −0 Sources/Transmute/Package+testModules.swift
  54. +42 −0 Sources/Transmute/fillModuleGraph().swift
  55. +31 −0 Sources/Transmute/sort().swift
  56. +55 −0 Sources/Transmute/transmute().swift
  57. +44 −0 Sources/Utility/ArrayExtensions.swift
  58. +2 −1 Sources/{sys → Utility}/File.swift
  59. +54 −0 Sources/Utility/Git.swift
  60. +25 −0 Sources/Utility/POSIXConvenience.swift
  61. 0 Sources/{sys → Utility}/Path.swift
  62. +25 −12 Sources/{sys → Utility}/Resources.swift
  63. 0 Sources/{sys → Utility}/StringExtensions.swift
  64. 0 Sources/{sys → Utility}/URL.swift
  65. +2 −2 Sources/{sys → Utility}/Verbosity.swift
  66. +10 −1 Sources/{sys → Utility}/misc.swift
  67. +7 −1 Sources/{sys → Utility}/walk.swift
  68. +0 −118 Sources/dep/Git.swift
  69. +0 −195 Sources/dep/Manifest+configureTargets.swift
  70. +0 −148 Sources/dep/Package.swift
  71. +0 −45 Sources/dep/Target.swift
  72. +0 −326 Sources/dep/get.swift
  73. +0 −371 Sources/dep/llbuild.swift
  74. +22 −22 Sources/libc/String+Linux.swift
  75. +22 −0 Sources/swift-build/Error.swift
  76. +4 −4 Sources/swift-build/initPackage.swift
  77. +35 −113 Sources/swift-build/main.swift
  78. +0 −44 Sources/swift-build/misc.swift
  79. +3 −9 Sources/swift-build/usage.swift
  80. +34 −0 Sources/swift-build/xp.swift
  81. +33 −0 Sources/swift-test/main.swift
  82. +23 −0 Sources/swift-test/test.swift
  83. +5 −784 Support/swiftpm.xcodeproj/project.pbxproj
  84. +14 −95 Support/swiftpm.xcodeproj/xcshareddata/xcschemes/swiftpm.xcscheme
  85. +0 −24 Tests/Functional/Info.plist
  86. +11 −11 Tests/Functional/TestDependencyResolution.swift
  87. +11 −14 Tests/Functional/TestInvalidLayouts.swift
  88. +47 −54 Tests/Functional/TestMiscellaneous.swift
  89. +75 −17 Tests/Functional/TestValidLayouts.swift
  90. +37 −9 Tests/Functional/Utilities.swift
  91. +0 −9 Tests/Functional/main.swift
  92. +7 −26 Tests/{dep → Get}/DependencyGraphTests.swift
  93. +8 −14 Tests/{dep → Get}/GetTests.swift
  94. +51 −16 Tests/{dep/GitTests.swift → Get/RawCloneTests.swift}
  95. 0 Tests/{dep → Get}/Utilities.swift
  96. +39 −0 Tests/LinuxMain.swift
  97. 0 Tests/{dep → ManifestParser}/Inputs/package-deps-manifest
  98. 0 Tests/{dep → ManifestParser}/Inputs/target-deps-manifest
  99. 0 Tests/{dep → ManifestParser}/Inputs/trivial-manifest
  100. +11 −12 Tests/{dep → ManifestParser}/ManifestTests.swift
  101. +4 −15 Tests/{PackageDescription/PackageDescriptionTests.swift → ManifestParser/SerializationTests.swift}
  102. +35 −11 Tests/{sys → ManifestParser}/TOMLTests.swift
  103. +1 −0 Tests/ManifestParser/Utilities.swift
  104. +0 −24 Tests/PackageDescription/Info.plist
  105. +23 −32 Tests/{dep → PackageDescription}/VersionTests.swift
  106. +0 −7 Tests/PackageDescription/main.swift
  107. +20 −16 Tests/{dep/UidTests.swift → PackageType/PackageNameTests.swift}
  108. +79 −63 Tests/{dep/TargetTests.swift → Transmute/ModuleTests.swift}
  109. +1 −0 Tests/Transmute/Utilities.swift
  110. +178 −0 Tests/Utility/FileTests.swift
  111. 0 Tests/Utility/Inputs/empty_file
  112. 0 Tests/{sys → Utility}/Inputs/regular_text_file
  113. +2 −10 Tests/{sys → Utility}/MiscTests.swift
  114. +8 −47 Tests/{sys → Utility}/PathTests.swift
  115. +11 −11 Tests/{sys → Utility}/ResourcesTests.swift
  116. +4 −13 Tests/{sys → Utility}/ShellTests.swift
  117. +6 −22 Tests/{sys → Utility}/StringTests.swift
  118. +0 −28 Tests/XCTestCaseProvider/Info.plist
  119. +0 −52 Tests/XCTestCaseProvider/XCTestCaseProvider.swift
  120. +0 −24 Tests/dep/Info.plist
  121. +0 −73 Tests/dep/PackageTests.swift
  122. +0 −28 Tests/dep/main.swift
  123. +0 −79 Tests/sys/FileTests.swift
  124. +0 −24 Tests/sys/Info.plist
  125. +0 −26 Tests/sys/main.swift
  126. +35 −178 Utilities/bootstrap
@@ -1,3 +1,13 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 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 PackageDescription
let package = Package(
@@ -1,3 +1,13 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 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 FisherYates
import PlayingCard
import DeckOfPlayingCards
@@ -1,3 +1,13 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 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 FisherYates
import PlayingCard
@@ -0,0 +1,5 @@
import PackageDescription
let package = Package(
name: "FooLib1",
targets: [Target(name: "cli", dependencies: ["FooLib1"])])
@@ -0,0 +1,3 @@
import FooLib1
print(FooLib1())
View
@@ -11,21 +11,52 @@
import PackageDescription
let package = Package(
name: "SwiftPackageManager",
name: "SwiftPM",
targets: [
Target(
name: "sys",
dependencies: [.Target(name: "POSIX")]),
Target(
/** “Swifty” POSIX functions from libc */
name: "POSIX",
dependencies: [.Target(name: "libc")]),
dependencies: ["libc"]),
Target(
/** Abstractions for common operations */
name: "Utility",
dependencies: ["POSIX"]),
Target(
/** Base types for the package-engine */
name: "PackageType",
dependencies: ["PackageDescription", "Utility"]), //FIXME dependency on PackageDescription sucks
Target( //FIXME Carpet is too general, we only need `Path`
name: "ManifestParser",
dependencies: ["PackageDescription", "PackageType"]),
Target(
/** Turns Packages into Modules & Products */
name: "Transmute",
dependencies: ["PackageDescription", "PackageType"]),
Target(
/** Fetches Packages and their dependencies */
name: "Get",
dependencies: ["ManifestParser"]),
Target(
name: "dep",
dependencies: [.Target(name: "sys"), .Target(name: "PackageDescription")]),
/** Builds Modules and Products */
name: "Build",
dependencies: ["PackageType"]),
Target(
name: "swift-get",
dependencies: [.Target(name: "dep")]),
/** Common components of both executables */
name: "Multitool",
dependencies: ["PackageType"]),
Target(
name: "swift-build",
dependencies: [.Target(name: "dep")]),
dependencies: ["Get", "Transmute", "Build", "Multitool"]),
Target(
name: "swift-test",
dependencies: ["Multitool"]),
])
// otherwise executables are auto-determined you could
// prevent this by asking for the auto-determined list
// here and editing it.
let dylib = Product(name: "PackageDescription", type: .Library(.Dynamic), modules: "PackageDescription")
products.append(dylib)
View
@@ -54,8 +54,6 @@ following options:
swiftpm/Utilities/bootstrap --swiftc path/to/snapshot/usr/bin/swiftc --sbt path/to/snapshot/usr/bin/swift-build-tool
`swiftc` and `swift-build-tool` are both executables provided as part of Swift downloadable snapshots, *they are **not** built from the sources in this repository*.
Please note, that the 2.2 release snapshot does not come with `swift-build-tool`, either download the *development* snapshot or build your own copy of `swift-llbuild`.
3. Using the Xcode Project in [Support](Support), this option requires:
* Xcode 7.3 (beta)
@@ -67,7 +65,7 @@ There is further development-oriented documentation in [Documentation/Internals]
## System Requirements
The package manager’s system requirements are the same as [those for Swift](https://github.com/apple/swift#system-requirements).
The package manager’s system requirements are the same as [those for Swift](https://github.com/apple/swift#system-requirements) with the caveat that the package manager requires Git at runtime as well as build-time.
## Contributing
@@ -8,4 +8,13 @@
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/
@_exported import func libc.exit
public enum Configuration {
case Debug, Release
var dirname: String {
switch self {
case .Debug: return "debug"
case .Release: return "release"
}
}
}
@@ -0,0 +1,41 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 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 Utility
import PackageType
struct IncrementalNode {
let module: SwiftModule
let prefix: String
var tempsPath: String {
return Path.join(prefix, "\(module.c99name).build")
}
var swiftModuleName: String {
return "\(module.c99name).swiftmodule"
}
var objectPaths: [String] {
return module.sources.relativePaths.map{ Path.join(tempsPath, "\($0).o") }
}
var outputs: [String] {
return [module.targetName] + objectPaths
}
var inputs: [String] {
return module.recursiveDependencies.map{ $0.targetName }
}
var moduleOutputPath: String {
return Path.join(prefix, swiftModuleName)
}
}
View
@@ -0,0 +1,63 @@
/*
This source file is part of the Swift.org open source project
Copyright 2015 - 2016 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 struct Utility.Path
import struct libc.FILE
import func libc.fclose
import POSIX
class YAML {
let path: String
private let fp: UnsafeMutablePointer<FILE>
init(path: String...) throws {
self.path = Path.join(path)
fp = try fopen(self.path, mode: .Write)
}
func close() {
fclose(fp)
}
func write(anys: Any...) throws {
var anys = anys
try fputs(anys.removeFirst() as! String, fp)
if !anys.isEmpty {
try fputs(anys.map(toYAML).joinWithSeparator(""), fp)
}
try fputs("\n", fp)
}
}
private func toYAML(any: Any) -> String {
func quote(input: String) -> String {
for c in input.characters {
if c == "@" || c == " " || c == "-" {
return "\"\(input)\""
}
}
return input
}
switch any {
case let string as String where string == "":
return "\"\""
case let string as String:
return string
case let array as [String]:
return "[" + array.map(quote).joinWithSeparator(", ") + "]"
case let bool as Bool:
return bool ? "true" : "false"
default:
fatalError("Unimplemented YAML type")
}
}
Oops, something went wrong.

0 comments on commit ae91219

Please sign in to comment.