fix linux tests formatting (#13)

motivation: use consistent formatting

changes: update generate_linux_tests to match the formatting rules we use: `swiftformat --self insert --patternlet inline --stripunusedargs unnamed-only --comments ignore`
This commit is contained in:
tomer doron 2019-04-12 10:57:04 -07:00 committed by GitHub
parent c730d4e761
commit feafca5bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 42 deletions

10
.swiftformat Normal file
View File

@ -0,0 +1,10 @@
# file options
# format options
--self insert
--patternlet inline
--stripunusedargs unnamed-only
--comments ignore
# rules

View File

@ -23,10 +23,10 @@ import XCTest
/// ///
#if os(Linux) || os(FreeBSD) #if os(Linux) || os(FreeBSD)
@testable import MetricsTests @testable import MetricsTests
XCTMain([ XCTMain([
testCase(MetricsExtensionsTests.allTests), testCase(MetricsExtensionsTests.allTests),
testCase(MetricsTests.allTests), testCase(MetricsTests.allTests),
]) ])
#endif #endif

View File

@ -23,23 +23,21 @@ import XCTest
/// ///
extension MetricsTests { extension MetricsTests {
static var allTests: [(String, (MetricsTests) -> () throws -> Void)] {
static var allTests : [(String, (MetricsTests) -> () throws -> Void)] { return [
return [ ("testCounters", testCounters),
("testCounters", testCounters), ("testCounterBlock", testCounterBlock),
("testCounterBlock", testCounterBlock), ("testRecorders", testRecorders),
("testRecorders", testRecorders), ("testRecordersInt", testRecordersInt),
("testRecordersInt", testRecordersInt), ("testRecordersFloat", testRecordersFloat),
("testRecordersFloat", testRecordersFloat), ("testRecorderBlock", testRecorderBlock),
("testRecorderBlock", testRecorderBlock), ("testTimers", testTimers),
("testTimers", testTimers), ("testTimerBlock", testTimerBlock),
("testTimerBlock", testTimerBlock), ("testTimerVariants", testTimerVariants),
("testTimerVariants", testTimerVariants), ("testGauge", testGauge),
("testGauge", testGauge), ("testGaugeBlock", testGaugeBlock),
("testGaugeBlock", testGaugeBlock), ("testMUX", testMUX),
("testMUX", testMUX), ("testCustomFactory", testCustomFactory),
("testCustomFactory", testCustomFactory), ]
] }
}
} }

View File

@ -23,13 +23,11 @@ import XCTest
/// ///
extension MetricsExtensionsTests { extension MetricsExtensionsTests {
static var allTests: [(String, (MetricsExtensionsTests) -> () throws -> Void)] {
static var allTests : [(String, (MetricsExtensionsTests) -> () throws -> Void)] { return [
return [ ("testTimerBlock", testTimerBlock),
("testTimerBlock", testTimerBlock), ("testTimerWithTimeInterval", testTimerWithTimeInterval),
("testTimerWithTimeInterval", testTimerWithTimeInterval), ("testTimerWithDispatchTime", testTimerWithDispatchTime),
("testTimerWithDispatchTime", testTimerWithDispatchTime), ]
] }
}
} }

View File

@ -71,17 +71,17 @@ def createExtensionFile(fileName, classes)
file.write "\n" file.write "\n"
for classArray in classes for classArray in classes
file.write 'extension ' + classArray[0] + " {\n\n" file.write 'extension ' + classArray[0] + " {\n"
file.write ' static var allTests : [(String, (' + classArray[0] + ") -> () throws -> Void)] {\n" file.write ' static var allTests: [(String, (' + classArray[0] + ") -> () throws -> Void)] {\n"
file.write " return [\n" file.write " return [\n"
for funcName in classArray[1] for funcName in classArray[1]
file.write ' ("' + funcName + '", ' + funcName + "),\n" file.write ' ("' + funcName + '", ' + funcName + "),\n"
end end
file.write " ]\n" file.write " ]\n"
file.write " }\n" file.write " }\n"
file.write "}\n\n" file.write "}\n"
end end
end end
end end
@ -96,10 +96,10 @@ def createLinuxMain(testsDirectory, allTestSubDirectories, files)
file.write "#if os(Linux) || os(FreeBSD)\n" file.write "#if os(Linux) || os(FreeBSD)\n"
for testSubDirectory in allTestSubDirectories.sort { |x, y| x <=> y } for testSubDirectory in allTestSubDirectories.sort { |x, y| x <=> y }
file.write ' @testable import ' + testSubDirectory + "\n" file.write ' @testable import ' + testSubDirectory + "\n"
end end
file.write "\n" file.write "\n"
file.write " XCTMain([\n" file.write " XCTMain([\n"
testCases = [] testCases = []
for classes in files for classes in files
@ -109,7 +109,7 @@ def createLinuxMain(testsDirectory, allTestSubDirectories, files)
end end
for testCase in testCases.sort { |x, y| x <=> y } for testCase in testCases.sort { |x, y| x <=> y }
file.write ' testCase(' + testCase + ".allTests),\n" file.write ' testCase(' + testCase + ".allTests),\n"
end end
file.write " ])\n" file.write " ])\n"
file.write "#endif\n" file.write "#endif\n"