Fix hashing of preaction when it has no path.
This commit is contained in:
parent
dd4e88da70
commit
851999f132
|
@ -24,7 +24,8 @@ public final class TargetActionsContentHasher: TargetActionsContentHashing {
|
|||
public func hash(targetActions: [TargetAction]) throws -> String {
|
||||
var stringsToHash: [String] = []
|
||||
for targetAction in targetActions {
|
||||
var pathsToHash: [AbsolutePath] = [targetAction.path ?? ""]
|
||||
var pathsToHash: [AbsolutePath] = []
|
||||
targetAction.path.map { pathsToHash.append($0) }
|
||||
pathsToHash.append(contentsOf: targetAction.inputPaths)
|
||||
pathsToHash.append(contentsOf: targetAction.inputFileListPaths)
|
||||
pathsToHash.append(contentsOf: targetAction.outputPaths)
|
||||
|
|
|
@ -35,7 +35,7 @@ final class TargetActionsContentHasherTests: TuistUnitTestCase {
|
|||
private func makeTargetAction(name: String = "1",
|
||||
order: TargetAction.Order = .pre,
|
||||
tool: String = "tool1",
|
||||
path: AbsolutePath = AbsolutePath("/path1"),
|
||||
path: AbsolutePath? = AbsolutePath("/path1"),
|
||||
arguments: [String] = ["arg1", "arg2"],
|
||||
inputPaths: [AbsolutePath] = [AbsolutePath("/inputPaths1")],
|
||||
inputFileListPaths: [AbsolutePath] = [AbsolutePath("/inputFileListPaths1")],
|
||||
|
@ -86,6 +86,36 @@ final class TargetActionsContentHasherTests: TuistUnitTestCase {
|
|||
XCTAssertEqual(mockContentHasher.hashStringsSpy, expected)
|
||||
}
|
||||
|
||||
func test_hash_targetAction_when_path_nil_callsMockHasherWithExpectedStrings() throws {
|
||||
// Given
|
||||
let inputPaths1Hash = "inputPaths1-hash"
|
||||
let inputFileListPaths1 = "inputFileListPaths1-hash"
|
||||
let outputPaths1 = "outputPaths1-hash"
|
||||
let outputFileListPaths1 = "outputFileListPaths1-hash"
|
||||
mockContentHasher.stubHashForPath[AbsolutePath("/inputPaths1")] = inputPaths1Hash
|
||||
mockContentHasher.stubHashForPath[AbsolutePath("/inputFileListPaths1")] = inputFileListPaths1
|
||||
mockContentHasher.stubHashForPath[AbsolutePath("/outputPaths1")] = outputPaths1
|
||||
mockContentHasher.stubHashForPath[AbsolutePath("/outputFileListPaths1")] = outputFileListPaths1
|
||||
let targetAction = makeTargetAction(path: nil)
|
||||
|
||||
// When
|
||||
_ = try subject.hash(targetActions: [targetAction])
|
||||
|
||||
// Then
|
||||
let expected = [
|
||||
inputPaths1Hash,
|
||||
inputFileListPaths1,
|
||||
outputPaths1,
|
||||
outputFileListPaths1,
|
||||
"1",
|
||||
"tool1",
|
||||
"pre",
|
||||
"arg1",
|
||||
"arg2",
|
||||
]
|
||||
XCTAssertEqual(mockContentHasher.hashStringsSpy, expected)
|
||||
}
|
||||
|
||||
func test_hash_targetAction_valuesAreNotHarcoded() throws {
|
||||
// Given
|
||||
let file2hash = "file2-content-hash"
|
||||
|
|
Loading…
Reference in New Issue