From 82f1abf91a4f9dcd6585b40c5b7298be54db10a4 Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Tue, 30 Aug 2022 18:59:12 -0500 Subject: [PATCH] Declare Hashable conformance for ArgumentVisibility In addition to being useful, this allows us to drop the `@testable` annotation for the ArgumentParser import in ArgumentParserTestHelpers, which resolves #463. --- .../Parsable Properties/ArgumentVisibility.swift | 2 +- .../ArgumentParserTestHelpers/TestHelpers.swift | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Sources/ArgumentParser/Parsable Properties/ArgumentVisibility.swift b/Sources/ArgumentParser/Parsable Properties/ArgumentVisibility.swift index 9570f5624..2f831e913 100644 --- a/Sources/ArgumentParser/Parsable Properties/ArgumentVisibility.swift +++ b/Sources/ArgumentParser/Parsable Properties/ArgumentVisibility.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// /// Visibility level of an argument's help. -public struct ArgumentVisibility { +public struct ArgumentVisibility: Hashable { /// Internal implementation of `ArgumentVisibility` to allow for easier API /// evolution. internal enum Representation { diff --git a/Sources/ArgumentParserTestHelpers/TestHelpers.swift b/Sources/ArgumentParserTestHelpers/TestHelpers.swift index 8fcd18196..9a0338c25 100644 --- a/Sources/ArgumentParserTestHelpers/TestHelpers.swift +++ b/Sources/ArgumentParserTestHelpers/TestHelpers.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -@testable import ArgumentParser +import ArgumentParser import ArgumentParserToolInfo import XCTest @@ -122,7 +122,7 @@ public func AssertHelp( let flag: String let includeHidden: Bool - switch visibility.base { + switch visibility { case .default: flag = "--help" includeHidden = false @@ -130,7 +130,10 @@ public func AssertHelp( flag = "--help-hidden" includeHidden = true case .private: - XCTFail("Should not be called.") + XCTFail("Should not be called.", file: file, line: line) + return + default: + XCTFail("Unrecognized visibility.", file: file, line: line) return } @@ -158,13 +161,16 @@ public func AssertHelp( ) { let includeHidden: Bool - switch visibility.base { + switch visibility { case .default: includeHidden = false case .hidden: includeHidden = true case .private: - XCTFail("Should not be called.") + XCTFail("Should not be called.", file: file, line: line) + return + default: + XCTFail("Unrecognized visibility.", file: file, line: line) return }