Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/LiteSupport/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public func runLite(substitutions: [(String, String)],
pathExtensions: Set<String>,
testDirPath: String?,
testLinePrefix: String,
parallelismLevel: ParallelismLevel = .none) throws -> Bool {
parallelismLevel: ParallelismLevel = .none,
successMessage: String = "All tests passed! 🎉") throws -> Bool {
let testRunner = try TestRunner(testDirPath: testDirPath,
substitutions: substitutions,
pathExtensions: pathExtensions,
testLinePrefix: testLinePrefix,
parallelismLevel: parallelismLevel)
parallelismLevel: parallelismLevel,
successMessage: successMessage)
return try testRunner.run()
}
9 changes: 7 additions & 2 deletions Sources/LiteSupport/TestRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ class TestRunner {
/// How to parallelize work.
let parallelismLevel: ParallelismLevel

/// The message to print if all the tests passed.
let successMessage: String

/// Creates a test runner that will execute all tests in the provided
/// directory.
/// - throws: A LiteError if the test directory is invalid.
init(testDirPath: String?, substitutions: [(String, String)],
pathExtensions: Set<String>, testLinePrefix: String,
parallelismLevel: ParallelismLevel) throws {
parallelismLevel: ParallelismLevel,
successMessage: String) throws {
let fm = FileManager.default
var isDir: ObjCBool = false
let testDirPath =
Expand All @@ -74,6 +78,7 @@ class TestRunner {
self.pathExtensions = pathExtensions
self.testLinePrefix = testLinePrefix
self.parallelismLevel = parallelismLevel
self.successMessage = successMessage
}

func discoverTests() throws -> [TestFile] {
Expand Down Expand Up @@ -167,7 +172,7 @@ class TestRunner {
""")

if failures == 0 {
print("All tests passed! 🎉".green.bold)
print(successMessage.green.bold)
return true
}
return false
Expand Down