Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kareman/testcommit
Locally test the latest commit to a software project. Supports Swift Package Manager and make.
https://github.com/kareman/testcommit
command-line-tool swift swift3 testing-tools
Last synced: 21 days ago
JSON representation
Locally test the latest commit to a software project. Supports Swift Package Manager and make.
- Host: GitHub
- URL: https://github.com/kareman/testcommit
- Owner: kareman
- License: mit
- Created: 2017-04-05T17:16:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-28T17:59:23.000Z (almost 8 years ago)
- Last Synced: 2024-11-29T23:08:41.319Z (3 months ago)
- Topics: command-line-tool, swift, swift3, testing-tools
- Language: Swift
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README

# testcommit
Locally test the latest commit to a software project. Supports Swift Package Manager and `make`.
This is mostly made as a demonstration of how to use [SwiftShell](https://github.com/kareman/SwiftShell) and [FileSmith](https://github.com/kareman/FileSmith). Especially this part:
```swift
if testdir.contains("Package.swift") {
// Use the version of Swift defined in ".swift-version".
// If that file does not exist, or that version is not installed, use the system default.
let dotversion = cleanctx.run("cat", ".swift-version").stdout
let fullversion = dotversion.characters.count > 8 ? dotversion : dotversion + "-RELEASE"
cleanctx.env["TOOLCHAINS"] = (
cleanctx.run("defaults", "read", "/Library/Developer/Toolchains/swift-\(fullversion).xctoolchain/Info", "CFBundleIdentifier")
|| cleanctx.run("echo", "swift")
).stdouttry cleanctx.runAndPrint("swift","build")
// If there are any unit tests, run them.
let packagedescription = cleanctx.run("swift", "package", "describe")
if packagedescription.succeeded {
if packagedescription.stdout.contains("Test module: true") {
try cleanctx.runAndPrint("swift", "test")
}
} else { // Swift < 3.1
let runtests = cleanctx.run("swift", "test")
if let error = runtests.error {
if !runtests.stderror.contains("no tests found to execute") {
main.stderror.write(runtests.stderror) // "swift test" prints results to stderror.
throw error
}
} else {
main.stderror.write(runtests.stderror)
}
}
}
```## Installation
```bash
git clone https://github.com/kareman/testcommit
cd testcommit
swift build -c release
cp .build/release/testcommit /usr/local/bin/testcommit
```## License
Released under the MIT License (MIT), http://opensource.org/licenses/MIT
Kåre Morstøl, [NotTooBad Software](http://nottoobadsoftware.com)