diff --git a/Tests/CoreTests/LinuxTestIndex.swift b/Tests/CoreTests/LinuxTestIndex.swift index f194e11f..fd7f93a9 100644 --- a/Tests/CoreTests/LinuxTestIndex.swift +++ b/Tests/CoreTests/LinuxTestIndex.swift @@ -1,50 +1,48 @@ // @generated by GenerateTestCaseProvider.swift +// swiftformat:disable all import XCTest #if os(Linux) - // Generated Test Extension for StringExtensionsTests - extension StringExtensionsTests { - static var allTests = [ - ("testUppercaseFirst", testUppercaseFirst), - ("testLowercaseFirst", testLowercaseFirst), - ("testSuffixSubstring", testSuffixSubstring), - ] - } - - // Generated Test Extension for ObjectiveCIRTests - extension ObjectiveCIRTests { - static var allTests = [ - ("testDirtyPropertyOption", testDirtyPropertyOption), - ("testDirtyPropertyOptionMultiWord", testDirtyPropertyOptionMultiWord), - ("testEnumTypeName", testEnumTypeName), - ("testEnumToStringName", testEnumToStringName), - ("testEnumFromStringName", testEnumFromStringName), - ("testStatementSyntax", testStatementSyntax), - ("testMsgSyntax", testMsgSyntax), - ("testBlockSyntax", testBlockSyntax), - ("testScopeSyntax", testScopeSyntax), - ("testNestedScopeSyntax", testNestedScopeSyntax), - ("testIfStmt", testIfStmt), - ("testElseIfStmt", testElseIfStmt), - ("testElseStmt", testElseStmt), - ("testIfElseStmt", testIfElseStmt), - ] - } - - // Generated Test Extension for LanguagesTests - extension LanguagesTests { - static var allTests = [ - ("testSnakeCaseToCamelCase", testSnakeCaseToCamelCase), - ("testSnakeCaseToPropertyName", testSnakeCaseToPropertyName), - ("testSnakeCaseToCapitalizedPropertyName", testSnakeCaseToCapitalizedPropertyName), - ("testReservedKeywordSubstitution", testReservedKeywordSubstitution), - ] - } - - // Generated Test Extension for ObjectiveCInitTests - extension ObjectiveCInitTests { - static var allTests = [ - ("testOneOfInit", testOneOfInit), - ] - } +// Generated Test Extension for LanguagesTests +extension LanguagesTests { + static var allTests = [ + ("testSnakeCaseToCamelCase", testSnakeCaseToCamelCase), + ("testSnakeCaseToPropertyName", testSnakeCaseToPropertyName), + ("testSnakeCaseToCapitalizedPropertyName", testSnakeCaseToCapitalizedPropertyName), + ("testReservedKeywordSubstitution", testReservedKeywordSubstitution) + ] +} +// Generated Test Extension for ObjectiveCIRTests +extension ObjectiveCIRTests { + static var allTests = [ + ("testDirtyPropertyOption", testDirtyPropertyOption), + ("testDirtyPropertyOptionMultiWord", testDirtyPropertyOptionMultiWord), + ("testEnumTypeName", testEnumTypeName), + ("testEnumToStringName", testEnumToStringName), + ("testEnumFromStringName", testEnumFromStringName), + ("testStatementSyntax", testStatementSyntax), + ("testMsgSyntax", testMsgSyntax), + ("testBlockSyntax", testBlockSyntax), + ("testScopeSyntax", testScopeSyntax), + ("testNestedScopeSyntax", testNestedScopeSyntax), + ("testIfStmt", testIfStmt), + ("testElseIfStmt", testElseIfStmt), + ("testElseStmt", testElseStmt), + ("testIfElseStmt", testIfElseStmt) + ] +} +// Generated Test Extension for ObjectiveCInitTests +extension ObjectiveCInitTests { + static var allTests = [ + ("testOneOfInit", testOneOfInit) + ] +} +// Generated Test Extension for StringExtensionsTests +extension StringExtensionsTests { + static var allTests = [ + ("testUppercaseFirst", testUppercaseFirst), + ("testLowercaseFirst", testLowercaseFirst), + ("testSuffixSubstring", testSuffixSubstring) + ] +} #endif diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index e54be545..18731c3a 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1,11 +1,12 @@ -@testable import CoreTests // @generated - Generated by GeneratedTestCaseProvider.swift +// swiftformat:disable all import XCTest +@testable import CoreTests var tests = [XCTestCaseEntry]() -tests += [testCase(StringExtensionsTests.allTests)] -tests += [testCase(ObjectiveCIRTests.allTests)] -tests += [testCase(LanguagesTests.allTests)] -tests += [testCase(ObjectiveCInitTests.allTests)] + tests += [testCase(LanguagesTests.allTests)] + tests += [testCase(ObjectiveCIRTests.allTests)] + tests += [testCase(ObjectiveCInitTests.allTests)] + tests += [testCase(StringExtensionsTests.allTests)] XCTMain(tests) diff --git a/Utility/GenerateTestCaseProvider.swift b/Utility/GenerateTestCaseProvider.swift index 71e3fc09..f1f40216 100755 --- a/Utility/GenerateTestCaseProvider.swift +++ b/Utility/GenerateTestCaseProvider.swift @@ -28,6 +28,7 @@ func printLinuxMain(withClassNames classNames: [String]) -> String { }.joined(separator: "\n") return [ "// @generated - Generated by GeneratedTestCaseProvider.swift", + "// swiftformat:disable all", "import XCTest", "@testable import CoreTests", "", @@ -91,11 +92,13 @@ func processDirectory(atPath path: String) { guard path != "" else { return } if let files = try? FileManager.default.contentsOfDirectory(atPath: path) { let generatedOutput = files + .sorted() .map { processFile(withPath: path + "/" + $0) } .filter { $0 != "" } .joined(separator: "\n") let output = [ "// @generated by GenerateTestCaseProvider.swift", + "// swiftformat:disable all", "import XCTest", "", "#if os(Linux)", diff --git a/Utility/lint.sh b/Utility/lint.sh index ad10823b..329f9fb3 100755 --- a/Utility/lint.sh +++ b/Utility/lint.sh @@ -2,8 +2,38 @@ set -eou pipefail +update_current_line() { + printf "\033[1A" # move cursor one line up + printf "\033[K" # delete till end of line + echo "$1" +} + +log_err() { + echo "❌ $1" +} + +log_success() { + update_current_line "✅ $1" +} + echo "Checking for lint errors with SwiftLint" swift run swiftlint lint --reporter emoji echo "Checking for formatting errors with SwiftFormat" swift run swiftformat --lint . + +echo "Checking if linux test index needs to be updated" +readonly TEMP_DIR=$(mktemp -d) +cp -R Tests "${TEMP_DIR}" +cp -R Utility "${TEMP_DIR}" +cp Makefile "${TEMP_DIR}" +(cd "${TEMP_DIR}" && make build_test_index_linux > /dev/null) +# Check if files changed, fail +if ! diff -r "${TEMP_DIR}/Tests" "Tests"; then + log_err "Linux test index is out-of-date. Please update with 'make build_test_index_linux' and commit the changes" + exit 1 +else + log_success "Linux test index is up-to-date!" +fi + + diff --git a/Utility/stable-output-test.sh b/Utility/stable-output-test.sh index 7dab0207..02f0a51c 100755 --- a/Utility/stable-output-test.sh +++ b/Utility/stable-output-test.sh @@ -21,7 +21,7 @@ for lang in ${lang_options[@]}; do update_current_line "[${lang}] Testing output is stable (test case ${i}/100)" treatment_lang_output_dir="$(mktemp -d)" $plank_bin --lang ${lang} --output_dir=${treatment_lang_output_dir} ${json_files} - if ! diff "${lang_output_dir}" "${treatment_lang_output_dir}"; then + if ! diff -r "${lang_output_dir}" "${treatment_lang_output_dir}"; then update_current_line "[${lang}] ❌ Output is unstable" exit 1 fi