From f82e9d95529b375ce97839558124b6117a2f4f66 Mon Sep 17 00:00:00 2001 From: F1248 Date: Tue, 31 Dec 2024 21:44:42 +0100 Subject: [PATCH 1/5] Improve build settings in Genius.xcodeproj/project.pbxproj: - enable aggressive analyses where available - increase compiler optimizations --- Genius.xcodeproj/project.pbxproj | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Genius.xcodeproj/project.pbxproj b/Genius.xcodeproj/project.pbxproj index f45e5be..7ca5cd8 100644 --- a/Genius.xcodeproj/project.pbxproj +++ b/Genius.xcodeproj/project.pbxproj @@ -210,11 +210,13 @@ CLANG_ANALYZER_GCD_PERFORMANCE = YES; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ANALYZER_OSOBJECT_C_STYLE_CAST = YES; CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; - CLANG_CXX_STANDARD_LIBRARY_HARDENING = debug; + CLANG_CXX_STANDARD_LIBRARY_HARDENING = extensive; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_STATIC_ANALYZER_MODE = deep; CLANG_TIDY_BUGPRONE_REDUNDANT_BRANCH_CONDITION = YES; @@ -246,14 +248,15 @@ CLANG_WARN_OBJC_INTERFACE_IVARS = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; - CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES_AGGRESSIVE; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; CODE_SIGN_ENTITLEMENTS = Genius/Genius.entitlements; @@ -279,7 +282,7 @@ GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; @@ -291,6 +294,7 @@ INFOPLIST_KEY_NSHumanReadableCopyright = "© 2024 F1248 "; LD_WARN_DUPLICATE_LIBRARIES = YES; LD_WARN_UNUSED_DYLIBS = YES; + LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 11.0; MARKETING_VERSION = 0.1.0; ONLY_ACTIVE_ARCH = YES; @@ -315,11 +319,13 @@ CLANG_ANALYZER_GCD_PERFORMANCE = YES; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_ANALYZER_OSOBJECT_C_STYLE_CAST = YES; CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; - CLANG_CXX_STANDARD_LIBRARY_HARDENING = debug; + CLANG_CXX_STANDARD_LIBRARY_HARDENING = extensive; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_STATIC_ANALYZER_MODE = deep; CLANG_TIDY_BUGPRONE_REDUNDANT_BRANCH_CONDITION = YES; @@ -351,14 +357,15 @@ CLANG_WARN_OBJC_INTERFACE_IVARS = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; - CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES_AGGRESSIVE; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; CODE_SIGN_ENTITLEMENTS = Genius/Genius.entitlements; @@ -385,7 +392,7 @@ GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; @@ -397,6 +404,7 @@ INFOPLIST_KEY_NSHumanReadableCopyright = "© 2024 F1248 "; LD_WARN_DUPLICATE_LIBRARIES = YES; LD_WARN_UNUSED_DYLIBS = YES; + LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 11.0; MARKETING_VERSION = 0.1.0; PRODUCT_BUNDLE_IDENTIFIER = dev.F1248.Genius; From 80df6d3f273e9513f462e21ef44abdd1e12b74df Mon Sep 17 00:00:00 2001 From: F1248 Date: Wed, 1 Jan 2025 15:12:01 +0100 Subject: [PATCH 2/5] Fix SwiftFormat when linting files created in a previous year --- .github/workflows/Build-Genius.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Build-Genius.yml b/.github/workflows/Build-Genius.yml index 298e95d..1d6463f 100644 --- a/.github/workflows/Build-Genius.yml +++ b/.github/workflows/Build-Genius.yml @@ -46,6 +46,8 @@ jobs: - name: Checkout uses: actions/checkout@main + with: + fetch-depth: 0 - name: Install SwiftFormat run: | From 27c7f1bdd470d77310cf8bc550f5bff48da8608f Mon Sep 17 00:00:00 2001 From: F1248 Date: Wed, 1 Jan 2025 15:05:07 +0100 Subject: [PATCH 3/5] Improve YAML format --- .github/workflows/Build-Genius.yml | 5 ++--- .github/workflows/Trigger-Deploy-to-Pages.yml | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Build-Genius.yml b/.github/workflows/Build-Genius.yml index 1d6463f..cf6207c 100644 --- a/.github/workflows/Build-Genius.yml +++ b/.github/workflows/Build-Genius.yml @@ -28,7 +28,6 @@ env: NSUnbufferedIO: YES jobs: - Build-Genius: name: Build Genius runs-on: macos-15 @@ -38,7 +37,6 @@ jobs: attestations: write steps: - - name: Prepare run: | set -o pipefail @@ -104,7 +102,8 @@ jobs: - name: Attest Build Provenance uses: actions/attest-build-provenance@main - with: { subject-path: Genius.zip } + with: + subject-path: Genius.zip - name: Upload Genius uses: actions/upload-artifact@main diff --git a/.github/workflows/Trigger-Deploy-to-Pages.yml b/.github/workflows/Trigger-Deploy-to-Pages.yml index 1f3ea97..0806d8c 100644 --- a/.github/workflows/Trigger-Deploy-to-Pages.yml +++ b/.github/workflows/Trigger-Deploy-to-Pages.yml @@ -14,13 +14,11 @@ concurrency: cancel-in-progress: true jobs: - Trigger-Deploy-to-Pages: name: Trigger Deploy to Pages runs-on: macos-15 steps: - - name: Trigger Deploy to Pages uses: actions/github-script@main with: From 3f0cad9f253d0b883f565ccd9a54da6a2e8a6aae Mon Sep 17 00:00:00 2001 From: F1248 Date: Wed, 1 Jan 2025 15:12:15 +0100 Subject: [PATCH 4/5] Add Tests --- .github/workflows/Build-Genius.yml | 3 + Genius.xcodeproj/project.pbxproj | 123 ++++++++++++++++++ GeniusTests/.swiftformat | 1 + .../OptionalComparisonOpearatorsTests.swift | 49 +++++++ .../OptionalEquationOpearatorsTests.swift | 29 +++++ .../OptionalLogicalOpearatorsTests.swift | 46 +++++++ 6 files changed, 251 insertions(+) create mode 100644 GeniusTests/.swiftformat create mode 100644 GeniusTests/OptionalComparisonOpearatorsTests.swift create mode 100644 GeniusTests/OptionalEquationOpearatorsTests.swift create mode 100644 GeniusTests/OptionalLogicalOpearatorsTests.swift diff --git a/.github/workflows/Build-Genius.yml b/.github/workflows/Build-Genius.yml index cf6207c..97c7041 100644 --- a/.github/workflows/Build-Genius.yml +++ b/.github/workflows/Build-Genius.yml @@ -79,6 +79,9 @@ jobs: unzip xcbeautify.zip echo "xcbeautify $(./xcbeautify --version) installed" + - name: Test Genius + run: xcodebuild test -scheme Genius -destination platform=macOS,arch=arm64 | ./xcbeautify --disable-logging --renderer github-actions + - name: Build Genius run: xcodebuild archive -scheme Genius -destination generic/platform=macOS -archivePath Genius | tee xcodebuild.log | ./xcbeautify --disable-logging --renderer github-actions diff --git a/Genius.xcodeproj/project.pbxproj b/Genius.xcodeproj/project.pbxproj index 7ca5cd8..8d392f4 100644 --- a/Genius.xcodeproj/project.pbxproj +++ b/Genius.xcodeproj/project.pbxproj @@ -10,6 +10,16 @@ A46854972D1729B500DB3E87 /* Defaults in Frameworks */ = {isa = PBXBuildFile; productRef = A46854962D1729B500DB3E87 /* Defaults */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + A4D9A1AE2D257055008D91E7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A42B35352BA2185B009E81AD /* Project object */; + proxyType = 1; + remoteGlobalIDString = A42B353C2BA2185B009E81AD; + remoteInfo = Genius; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ A42B353D2BA2185B009E81AD /* Genius.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Genius.app; sourceTree = BUILT_PRODUCTS_DIR; }; A438B3FA2CA346C600F8DF17 /* LICENSE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.txt; sourceTree = ""; }; @@ -20,6 +30,7 @@ A452AFF22BBF2CAB00760569 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; usesTabs = 0; }; A47BFC592C72116700B88607 /* README_DE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README_DE.md; sourceTree = ""; }; A4844FF82C73E08C0021E6E8 /* install.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = install.sh; sourceTree = ""; }; + A4D9A1AA2D257055008D91E7 /* GeniusTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GeniusTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A4EB1C9A2BCC3F8200DF01A6 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; /* End PBXFileReference section */ @@ -31,6 +42,13 @@ ); target = A42B353C2BA2185B009E81AD /* Genius */; }; + A4D9A1BB2D257061008D91E7 /* Exceptions for "GeniusTests" folder in "GeniusTests" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + .swiftformat, + ); + target = A4D9A1A92D257055008D91E7 /* GeniusTests */; + }; /* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ /* Begin PBXFileSystemSynchronizedRootGroup section */ @@ -48,6 +66,14 @@ path = Genius; sourceTree = ""; }; + A4D9A1AB2D257055008D91E7 /* GeniusTests */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + A4D9A1BB2D257061008D91E7 /* Exceptions for "GeniusTests" folder in "GeniusTests" target */, + ); + path = GeniusTests; + sourceTree = ""; + }; /* End PBXFileSystemSynchronizedRootGroup section */ /* Begin PBXFrameworksBuildPhase section */ @@ -59,6 +85,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A4D9A1A72D257055008D91E7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -72,6 +105,7 @@ A43BD9C32C729A680049953D /* .swiftformat */, A452AFF22BBF2CAB00760569 /* .swiftlint.yml */, A47D8B992C26145300A0E4CF /* Genius */, + A4D9A1AB2D257055008D91E7 /* GeniusTests */, A4844FF82C73E08C0021E6E8 /* install.sh */, A438B3FA2CA346C600F8DF17 /* LICENSE.txt */, A47BFC592C72116700B88607 /* README_DE.md */, @@ -85,6 +119,7 @@ isa = PBXGroup; children = ( A42B353D2BA2185B009E81AD /* Genius.app */, + A4D9A1AA2D257055008D91E7 /* GeniusTests.xctest */, ); name = Products; sourceTree = ""; @@ -114,6 +149,30 @@ productReference = A42B353D2BA2185B009E81AD /* Genius.app */; productType = "com.apple.product-type.application"; }; + A4D9A1A92D257055008D91E7 /* GeniusTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A4D9A1B22D257055008D91E7 /* Build configuration list for PBXNativeTarget "GeniusTests" */; + buildPhases = ( + A4D9A1A62D257055008D91E7 /* Sources */, + A4D9A1A72D257055008D91E7 /* Frameworks */, + A4D9A1A82D257055008D91E7 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + A4D9A1BD2D257090008D91E7 /* PBXTargetDependency */, + A4D9A1AF2D257055008D91E7 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + A4D9A1AB2D257055008D91E7 /* GeniusTests */, + ); + name = GeniusTests; + packageProductDependencies = ( + ); + productName = GeniusTests; + productReference = A4D9A1AA2D257055008D91E7 /* GeniusTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -121,11 +180,16 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 1620; LastUpgradeCheck = 1620; TargetAttributes = { A42B353C2BA2185B009E81AD = { CreatedOnToolsVersion = 15.3; }; + A4D9A1A92D257055008D91E7 = { + CreatedOnToolsVersion = 16.2; + TestTargetID = A42B353C2BA2185B009E81AD; + }; }; }; buildConfigurationList = A42B35382BA2185B009E81AD /* Build configuration list for PBXProject "Genius" */; @@ -147,6 +211,7 @@ projectRoot = ""; targets = ( A42B353C2BA2185B009E81AD /* Genius */, + A4D9A1A92D257055008D91E7 /* GeniusTests */, ); }; /* End PBXProject section */ @@ -159,6 +224,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A4D9A1A82D257055008D91E7 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -191,6 +263,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A4D9A1A62D257055008D91E7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -198,6 +277,15 @@ isa = PBXTargetDependency; productRef = A4672DDA2C61207100C933CB /* SwiftLintBuildToolPlugin */; }; + A4D9A1AF2D257055008D91E7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A42B353C2BA2185B009E81AD /* Genius */; + targetProxy = A4D9A1AE2D257055008D91E7 /* PBXContainerItemProxy */; + }; + A4D9A1BD2D257090008D91E7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + productRef = A4D9A1BC2D257090008D91E7 /* SwiftLintBuildToolPlugin */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -261,6 +349,7 @@ CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; CODE_SIGN_ENTITLEMENTS = Genius/Genius.entitlements; CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -431,6 +520,26 @@ }; name = Release; }; + A4D9A1B02D257055008D91E7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + LD_WARN_UNUSED_DYLIBS = NO; + PRODUCT_BUNDLE_IDENTIFIER = dev.F1248.GeniusTests; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Genius.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Genius"; + }; + name = Debug; + }; + A4D9A1B12D257055008D91E7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + LD_WARN_UNUSED_DYLIBS = NO; + PRODUCT_BUNDLE_IDENTIFIER = dev.F1248.GeniusTests; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Genius.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Genius"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -452,6 +561,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A4D9A1B22D257055008D91E7 /* Build configuration list for PBXNativeTarget "GeniusTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A4D9A1B02D257055008D91E7 /* Debug */, + A4D9A1B12D257055008D91E7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ @@ -484,6 +602,11 @@ package = A46854952D1729B500DB3E87 /* XCRemoteSwiftPackageReference "Defaults" */; productName = Defaults; }; + A4D9A1BC2D257090008D91E7 /* SwiftLintBuildToolPlugin */ = { + isa = XCSwiftPackageProductDependency; + package = A4672DD92C61205000C933CB /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */; + productName = "plugin:SwiftLintBuildToolPlugin"; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = A42B35352BA2185B009E81AD /* Project object */; diff --git a/GeniusTests/.swiftformat b/GeniusTests/.swiftformat new file mode 100644 index 0000000..be362c1 --- /dev/null +++ b/GeniusTests/.swiftformat @@ -0,0 +1 @@ +--header "\n{file}\nGeniusTests\n\n© {created.year} F1248 \nSee LICENSE.txt for license information.\n" diff --git a/GeniusTests/OptionalComparisonOpearatorsTests.swift b/GeniusTests/OptionalComparisonOpearatorsTests.swift new file mode 100644 index 0000000..68a32c7 --- /dev/null +++ b/GeniusTests/OptionalComparisonOpearatorsTests.swift @@ -0,0 +1,49 @@ +// +// OptionalComparisonOpearatorsTests.swift +// GeniusTests +// +// © 2025 F1248 +// See LICENSE.txt for license information. +// + +@testable import Genius +import Testing + +struct OptionalComparisonOpearatorsTests { + + @Test + func lessThan() { + #expect((0 ? 0) == true) + #expect((0 >? 1) == false) + #expect((0 >? nil) == nil) + #expect((nil >? 0) == nil) + #expect((nil as Int? >? nil) == nil) + } + + @Test + func lessThanOrEqualTo() { + #expect((0 <=? 1) == true) + #expect((1 <=? 0) == false) + #expect((0 <=? nil) == nil) + #expect((nil <=? 0) == nil) + #expect((nil as Int? <=? nil) == nil) + } + + @Test + func greaterThanOrEqualTo() { + #expect((1 >=? 0) == true) + #expect((0 >=? 1) == false) + #expect((0 >=? nil) == nil) + #expect((nil >=? 0) == nil) + #expect((nil as Int? >=? nil) == nil) + } +} diff --git a/GeniusTests/OptionalEquationOpearatorsTests.swift b/GeniusTests/OptionalEquationOpearatorsTests.swift new file mode 100644 index 0000000..f8c2d9a --- /dev/null +++ b/GeniusTests/OptionalEquationOpearatorsTests.swift @@ -0,0 +1,29 @@ +// +// OptionalEquationOpearatorsTests.swift +// GeniusTests +// +// © 2025 F1248 +// See LICENSE.txt for license information. +// + +@testable import Genius +import Testing + +struct OptionalEquationOpearatorsTests { + + @Test + func equalTo() { + #expect((0 ==? 1) == false) + #expect((0 ==? nil) == nil) + #expect((nil ==? 0) == nil) + #expect((nil as Int? ==? nil) == nil) + } + + @Test + func notEqualTo() { + #expect((0 !=? 1) == true) + #expect((0 !=? nil) == nil) + #expect((nil !=? 0) == nil) + #expect((nil as Int? !=? nil) == nil) + } +} diff --git a/GeniusTests/OptionalLogicalOpearatorsTests.swift b/GeniusTests/OptionalLogicalOpearatorsTests.swift new file mode 100644 index 0000000..56ce6bc --- /dev/null +++ b/GeniusTests/OptionalLogicalOpearatorsTests.swift @@ -0,0 +1,46 @@ +// +// OptionalLogicalOpearatorsTests.swift +// GeniusTests +// +// © 2025 F1248 +// See LICENSE.txt for license information. +// + +@testable import Genius +import Testing + +struct OptionalLogicalOpearatorsTests { + + @Test + func negation() { + #expect(!?true == false) + #expect(!?false == true) + #expect(!?nil == nil) + } + + @Test + func conjunction() { + #expect((true &&? true) == true) + #expect((false &&? false) == false) + #expect((false &&? true) == false) + #expect((true &&? false) == false) + #expect((false &&? nil) == false) + #expect((nil &&? false) == false) + #expect((true &&? nil) == nil) + #expect((nil &&? true) == nil) + #expect((nil &&? nil) == nil) + } + + @Test + func disjunction() { + #expect((false ||? false) == false) + #expect((true ||? true) == true) + #expect((true ||? false) == true) + #expect((false ||? true) == true) + #expect((true ||? nil) == true) + #expect((nil ||? true) == true) + #expect((false ||? nil) == nil) + #expect((nil ||? false) == nil) + #expect((nil ||? nil) == nil) + } +} From 8c5dffa56cea7f83868386b2556896a561e5790c Mon Sep 17 00:00:00 2001 From: F1248 Date: Wed, 1 Jan 2025 15:46:15 +0100 Subject: [PATCH 5/5] Fix build and test steps not failing when commands fail --- .github/workflows/Build-Genius.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build-Genius.yml b/.github/workflows/Build-Genius.yml index 97c7041..6579896 100644 --- a/.github/workflows/Build-Genius.yml +++ b/.github/workflows/Build-Genius.yml @@ -39,7 +39,6 @@ jobs: steps: - name: Prepare run: | - set -o pipefail defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -boolean true - name: Checkout @@ -80,10 +79,14 @@ jobs: echo "xcbeautify $(./xcbeautify --version) installed" - name: Test Genius - run: xcodebuild test -scheme Genius -destination platform=macOS,arch=arm64 | ./xcbeautify --disable-logging --renderer github-actions + run: | + set -o pipefail + xcodebuild test -scheme Genius -destination platform=macOS,arch=arm64 | ./xcbeautify --disable-logging --renderer github-actions - name: Build Genius - run: xcodebuild archive -scheme Genius -destination generic/platform=macOS -archivePath Genius | tee xcodebuild.log | ./xcbeautify --disable-logging --renderer github-actions + run: | + set -o pipefail + xcodebuild archive -scheme Genius -destination generic/platform=macOS -archivePath Genius | tee xcodebuild.log | ./xcbeautify --disable-logging --renderer github-actions - name: Run SwiftLint Analyzer Rules run: ./swiftlint analyze --strict --reporter github-actions-logging --compiler-log-path xcodebuild.log Genius