Skip to content

Commit

Permalink
Add PluginLibraryTests on Linux
Browse files Browse the repository at this point in the history
This pointed out a bad test:  Test_Descriptor in SwiftProtobufTests
was put in to to verify descriptor support in the runtime library,
but the runtime library isn't supposed to support descriptors.
So I just removed it.
  • Loading branch information
tbkka committed May 12, 2017
1 parent 3c8ea6e commit b8d642f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 43 deletions.
1 change: 1 addition & 0 deletions CollectTests.awk
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ BEGIN {
printf("\n")
printf("import XCTest\n")
printf("@testable import SwiftProtobufTests\n")
printf("@testable import PluginLibraryTests\n")
printf("\n")
printf("private func run_test(test:() -> ()) throws {\n")
printf(" test()\n")
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ all: build
# (Someday, 'swift test' will learn how to auto-discover test cases on Linux,
# at which time this will no longer be needed.)
build:
@${AWK} -f CollectTests.awk Tests/SwiftProtobufTests/Test_*.swift > Tests/LinuxMain.swift.new
@${AWK} -f CollectTests.awk Tests/*/Test_*.swift > Tests/LinuxMain.swift.new
@if ! cmp -s Tests/LinuxMain.swift.new Tests/LinuxMain.swift; then \
cp Tests/LinuxMain.swift.new Tests/LinuxMain.swift; \
echo "FYI: Tests/LinuxMain.swift Updated"; \
Expand Down
51 changes: 42 additions & 9 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import XCTest
@testable import SwiftProtobufTests
@testable import PluginLibraryTests

private func run_test(test:() -> ()) throws {
test()
Expand All @@ -16,6 +17,44 @@ private func run_test(test:() throws -> ()) throws {



extension Test_Descriptor {
static var allTests: [(String, (XCTestCase) throws -> ())] {
return [
("testParsing", {try run_test(test:($0 as! Test_Descriptor).testParsing)}),
("testLookup", {try run_test(test:($0 as! Test_Descriptor).testLookup)}),
("testParents", {try run_test(test:($0 as! Test_Descriptor).testParents)}),
("testFields", {try run_test(test:($0 as! Test_Descriptor).testFields)}),
("testExtensions", {try run_test(test:($0 as! Test_Descriptor).testExtensions)})
]
}
}

extension Test_NamingUtils {
static var allTests: [(String, (XCTestCase) throws -> ())] {
return [
("testTypePrefix", {try run_test(test:($0 as! Test_NamingUtils).testTypePrefix)}),
("testStrip_protoPrefix", {try run_test(test:($0 as! Test_NamingUtils).testStrip_protoPrefix)}),
("testCanStripPrefix", {try run_test(test:($0 as! Test_NamingUtils).testCanStripPrefix)}),
("testSanitize_messageName", {try run_test(test:($0 as! Test_NamingUtils).testSanitize_messageName)}),
("testSanitize_enumName", {try run_test(test:($0 as! Test_NamingUtils).testSanitize_enumName)}),
("testSanitize_oneofName", {try run_test(test:($0 as! Test_NamingUtils).testSanitize_oneofName)}),
("testSanitize_fieldName", {try run_test(test:($0 as! Test_NamingUtils).testSanitize_fieldName)}),
("testSanitize_enumCaseName", {try run_test(test:($0 as! Test_NamingUtils).testSanitize_enumCaseName)}),
("testSanitize_messageScopedExtensionName", {try run_test(test:($0 as! Test_NamingUtils).testSanitize_messageScopedExtensionName)}),
("testToCamelCase", {try run_test(test:($0 as! Test_NamingUtils).testToCamelCase)})
]
}
}

extension Test_SwiftLanguage {
static var allTests: [(String, (XCTestCase) throws -> ())] {
return [
("testIsValidSwiftIdentifier", {try run_test(test:($0 as! Test_SwiftLanguage).testIsValidSwiftIdentifier)}),
("testIsNotValidSwiftIdentifier", {try run_test(test:($0 as! Test_SwiftLanguage).testIsNotValidSwiftIdentifier)})
]
}
}

extension Test_AllTypes {
static var allTests: [(String, (XCTestCase) throws -> ())] {
return [
Expand Down Expand Up @@ -365,14 +404,6 @@ extension Test_Conformance {
}
}

extension Test_Descriptor {
static var allTests: [(String, (XCTestCase) throws -> ())] {
return [
("testExists", {try run_test(test:($0 as! Test_Descriptor).testExists)})
]
}
}

extension Test_Duration {
static var allTests: [(String, (XCTestCase) throws -> ())] {
return [
Expand Down Expand Up @@ -1121,14 +1152,16 @@ extension Test_Wrappers {

XCTMain(
[
(testCaseClass: Test_Descriptor.self, allTests: Test_Descriptor.allTests),
(testCaseClass: Test_NamingUtils.self, allTests: Test_NamingUtils.allTests),
(testCaseClass: Test_SwiftLanguage.self, allTests: Test_SwiftLanguage.allTests),
(testCaseClass: Test_AllTypes.self, allTests: Test_AllTypes.allTests),
(testCaseClass: Test_AllTypes_Proto3.self, allTests: Test_AllTypes_Proto3.allTests),
(testCaseClass: Test_Any.self, allTests: Test_Any.allTests),
(testCaseClass: Test_Api.self, allTests: Test_Api.allTests),
(testCaseClass: Test_BasicFields_Access_Proto2.self, allTests: Test_BasicFields_Access_Proto2.allTests),
(testCaseClass: Test_BasicFields_Access_Proto3.self, allTests: Test_BasicFields_Access_Proto3.allTests),
(testCaseClass: Test_Conformance.self, allTests: Test_Conformance.allTests),
(testCaseClass: Test_Descriptor.self, allTests: Test_Descriptor.allTests),
(testCaseClass: Test_Duration.self, allTests: Test_Duration.allTests),
(testCaseClass: Test_Empty.self, allTests: Test_Empty.allTests),
(testCaseClass: Test_Enum.self, allTests: Test_Enum.allTests),
Expand Down
33 changes: 0 additions & 33 deletions Tests/SwiftProtobufTests/Test_Descriptor.swift

This file was deleted.

0 comments on commit b8d642f

Please sign in to comment.