Skip to content

Commit

Permalink
Update tests on Linux & configure sourcery to automate this
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Apr 16, 2020
1 parent 959cb6f commit 78e791e
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .sourcery/LinuxMain.stencil
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@testable import AnyLintTests
@testable import Utility
import XCTest

// swiftlint:disable line_length file_length

{% for type in types.classes|based:"XCTestCase" %}
extension {{ type.name }} {
static var allTests: [(String, ({{ type.name }}) -> () throws -> Void)] = [
{% for method in type.methods where method.parameters.count == 0 and method.shortName|hasPrefix:"test" and method|!annotated:"skipTestOnLinux" %} ("{{ method.shortName }}", {{ method.shortName }}){% if not forloop.last %},{% endif %}
{% endfor %}]
}

{% endfor %}
XCTMain([
{% for type in types.classes|based:"XCTestCase" %} testCase({{ type.name }}.allTests){% if not forloop.last %},{% endif %}
{% endfor %}])
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ Thank you very much for any donation, it really helps out a lot! 💯

Contributions are welcome. Feel free to open an issue on GitHub with your ideas or implement an idea yourself and post a pull request. If you want to contribute code, please try to follow the same syntax and semantic in your **commit messages** (see rationale [here](http://chris.beams.io/posts/git-commit/)). Also, please make sure to add an entry to the `CHANGELOG.md` file which explains your change.

To update the Linux tests, run [Sourcery](https://github.com/krzysztofzablocki/Sourcery) like this:

```bash
sourcery --sources Tests --templates .sourcery/LinuxMain.stencil --output .sourcery --force-parse generated && mv .sourcery/LinuxMain.generated.swift Tests/LinuxMain.swift
```

## License

This library is released under the [MIT License](http://opensource.org/licenses/MIT). See LICENSE for details.
94 changes: 94 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Generated using Sourcery 0.17.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

@testable import AnyLintTests
@testable import Utility
import XCTest

// swiftlint:disable line_length file_length

extension AnyLintCLITests {
static var allTests: [(String, (AnyLintCLITests) -> () throws -> Void)] = [
("testExample", testExample)
]
}

extension AutoCorrectionTests {
static var allTests: [(String, (AutoCorrectionTests) -> () throws -> Void)] = [
("testInitWithDictionaryLiteral", testInitWithDictionaryLiteral)
]
}

extension CheckInfoTests {
static var allTests: [(String, (CheckInfoTests) -> () throws -> Void)] = [
("testInitWithStringLiteral", testInitWithStringLiteral)
]
}

extension FileContentsCheckerTests {
static var allTests: [(String, (FileContentsCheckerTests) -> () throws -> Void)] = [
("testPerformCheck", testPerformCheck)
]
}

extension FilePathsCheckerTests {
static var allTests: [(String, (FilePathsCheckerTests) -> () throws -> Void)] = [
("testPerformCheck", testPerformCheck)
]
}

extension FilesSearchTests {
static var allTests: [(String, (FilesSearchTests) -> () throws -> Void)] = [
("testAllFilesWithinPath", testAllFilesWithinPath)
]
}

extension LintTests {
static var allTests: [(String, (LintTests) -> () throws -> Void)] = [
("testValidateRegexMatchesForEach", testValidateRegexMatchesForEach),
("testValidateRegexDoesNotMatchAny", testValidateRegexDoesNotMatchAny),
("testValidateAutocorrectsAllExamplesWithAnonymousGroups", testValidateAutocorrectsAllExamplesWithAnonymousGroups),
("testValidateAutocorrectsAllExamplesWithNamedGroups", testValidateAutocorrectsAllExamplesWithNamedGroups)
]
}

extension LoggerTests {
static var allTests: [(String, (LoggerTests) -> () throws -> Void)] = [
("testMessage", testMessage)
]
}

extension RegexExtTests {
static var allTests: [(String, (RegexExtTests) -> () throws -> Void)] = [
("testInitWithStringLiteral", testInitWithStringLiteral),
("testInitWithDictionaryLiteral", testInitWithDictionaryLiteral),
("testStringLiteralInit", testStringLiteralInit)
]
}

extension StatisticsTests {
static var allTests: [(String, (StatisticsTests) -> () throws -> Void)] = [
("testFoundViolationsInCheck", testFoundViolationsInCheck),
("testLogSummary", testLogSummary)
]
}

extension ViolationTests {
static var allTests: [(String, (ViolationTests) -> () throws -> Void)] = [
("testLocationMessage", testLocationMessage)
]
}

XCTMain([
testCase(AnyLintCLITests.allTests),
testCase(AutoCorrectionTests.allTests),
testCase(CheckInfoTests.allTests),
testCase(FileContentsCheckerTests.allTests),
testCase(FilePathsCheckerTests.allTests),
testCase(FilesSearchTests.allTests),
testCase(LintTests.allTests),
testCase(LoggerTests.allTests),
testCase(RegexExtTests.allTests),
testCase(StatisticsTests.allTests),
testCase(ViolationTests.allTests)
])

0 comments on commit 78e791e

Please sign in to comment.