Skip to content

Commit 6ab370c

Browse files
committed
Make tests available in Linux.
1 parent 49431cc commit 6ab370c

File tree

5 files changed

+95
-8
lines changed

5 files changed

+95
-8
lines changed

Tests/CommandLineKitTests/AnsiCodesTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ class AnsiCodesTests: XCTestCase {
5858
func testHomeCursor() {
5959
XCTAssertEqual(AnsiCodes.homeCursor, "\u{001B}[H")
6060
}
61+
62+
static let allTests = [
63+
("testGenerateEscapeCode", testGenerateEscapeCode),
64+
("testEraseRight", testEraseRight),
65+
("testCursorForward", testCursorForward),
66+
("testClearScreen", testClearScreen),
67+
("testHomeCursor", testHomeCursor),
68+
]
6169
}

Tests/CommandLineKitTests/EditStateTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,19 @@ class EditStateTests: XCTestCase {
175175
XCTAssertEqual(s.buffer, "eHllo")
176176
XCTAssertEqual(s.location, s.buffer.index(s.buffer.startIndex, offsetBy: 2))
177177
}
178+
179+
static let allTests = [
180+
("testInitEmptyBuffer", testInitEmptyBuffer),
181+
("testInsertCharacter", testInsertCharacter),
182+
("testBackspace", testBackspace),
183+
("testMoveLeft", testMoveLeft),
184+
("testMoveRight", testMoveRight),
185+
("testMoveHome", testMoveHome),
186+
("testMoveEnd", testMoveEnd),
187+
("testRemovePreviousWord", testRemovePreviousWord),
188+
("testDeleteToEndOfLine", testDeleteToEndOfLine),
189+
("testDeleteCharacter", testDeleteCharacter),
190+
("testEraseCharacterRight", testEraseCharacterRight),
191+
("testSwapCharacters", testSwapCharacters),
192+
]
178193
}

Tests/CommandLineKitTests/FlagTests.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ import XCTest
3636

3737
class FlagTests: XCTestCase {
3838

39-
override func setUp() {
40-
super.setUp()
41-
}
42-
43-
override func tearDown() {
44-
super.tearDown()
45-
}
46-
4739
func testLongFlagNames2() throws {
4840
let flags = Flags(["--one", "--four", "912", "--three", "--five", "-3.141",
4941
"--six", "six", "seven"])
@@ -106,4 +98,10 @@ class FlagTests: XCTestCase {
10698
XCTAssertNil(seven.value)
10799
XCTAssert(flags.parameters.count == 1 && flags.parameters[0] == "seven")
108100
}
101+
102+
static let allTests = [
103+
("testLongFlagNames2", testLongFlagNames2),
104+
("testLongFlagNames", testLongFlagNames),
105+
("testShortFlagNames", testShortFlagNames),
106+
]
109107
}

Tests/CommandLineKitTests/LineReaderHistoryTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import XCTest
3838
@testable import CommandLineKit
3939

4040
class LineReaderHistoryTests: XCTestCase {
41+
4142
func testHistoryAddItem() {
4243
let h = LineReaderHistory()
4344
h.add("Test")
@@ -171,4 +172,20 @@ class LineReaderHistoryTests: XCTestCase {
171172
XCTAssertEqual(h.historyItems.count, 2)
172173
XCTAssertEqual(h.historyItems, ["Test 2", "Test 3"])
173174
}
175+
176+
static let allTests = [
177+
("testHistoryAddItem", testHistoryAddItem),
178+
("testHistoryDoesNotAddDuplicatedLines", testHistoryDoesNotAddDuplicatedLines),
179+
("testHistoryHonorsMaxLength", testHistoryHonorsMaxLength),
180+
("testHistoryRemovesEntriesWhenMaxLengthIsSet", testHistoryRemovesEntriesWhenMaxLengthIsSet),
181+
("testHistoryNavigationReturnsNilWhenHistoryEmpty",
182+
testHistoryNavigationReturnsNilWhenHistoryEmpty),
183+
("testHistoryNavigationReturnsSingleItemWhenHistoryHasOneItem",
184+
testHistoryNavigationReturnsSingleItemWhenHistoryHasOneItem),
185+
("testHistoryStopsAtBeginning", testHistoryStopsAtBeginning),
186+
("testHistoryNavigationStopsAtEnd", testHistoryNavigationStopsAtEnd),
187+
("testHistorySavesToFile", testHistorySavesToFile),
188+
("testHistoryLoadsFromFile", testHistoryLoadsFromFile),
189+
("testHistoryLoadingRespectsMaxLength", testHistoryLoadingRespectsMaxLength),
190+
]
174191
}

Tests/LinuxMain.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// LinuxMain.swift
3+
// CommandLineKitTests
4+
//
5+
// Created by Matthias Zenger on 02/06/2018.
6+
// Copyright © 2018 Google LLC
7+
//
8+
// Redistribution and use in source and binary forms, with or without
9+
// modification, are permitted provided that the following conditions are met:
10+
//
11+
// * Redistributions of source code must retain the above copyright notice,
12+
// this list of conditions and the following disclaimer.
13+
//
14+
// * Redistributions in binary form must reproduce the above copyright notice,
15+
// this list of conditions and the following disclaimer in the documentation
16+
// and/or other materials provided with the distribution.
17+
//
18+
// * Neither the name of the copyright holder nor the names of its contributors
19+
// may be used to endorse or promote products derived from this software without
20+
// specific prior written permission.
21+
//
22+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23+
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24+
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26+
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27+
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29+
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31+
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
//
33+
34+
#if os(Linux)
35+
36+
import XCTest
37+
@testable import CommandLineKitTests
38+
39+
XCTMain(
40+
[
41+
testCase(FlagTests.allTests),
42+
testCase(LineReaderHistoryTests.allTests),
43+
testCase(EditStateTests.allTests),
44+
testCase(AnsiCodesTests.allTests),
45+
]
46+
)
47+
48+
#endif
49+

0 commit comments

Comments
 (0)