@@ -82,6 +82,68 @@ steps:
8282 Expect.sequenceEqual nodeIds1 nodeIds2 " "
8383 Expect.sequenceEqual edgeIds1 edgeIds2 " "
8484
85+ testCase " building same processing unit instance twice is deterministic" <| fun () ->
86+ let yaml = """ cwlVersion: v1.2
87+ class: Workflow
88+ inputs: {}
89+ outputs: {}
90+ steps:
91+ step1:
92+ run: ./tool.cwl
93+ in: {}
94+ out: [out]"""
95+ let processingUnit = Decode.decodeCWLProcessingUnit yaml
96+ let resolvedTool = Decode.decodeCommandLineTool TestObjects.CWL.CommandLineTool.cwlFile
97+ let options =
98+ WorkflowGraphBuildOptions.defaultOptions
99+ |> WorkflowGraphBuildOptions.withRootWorkflowFilePath ( Some " workflow.cwl" )
100+ |> WorkflowGraphBuildOptions.withTryResolveRunPath ( Some ( fun path ->
101+ if path.EndsWith( " tool.cwl" ) then Some ( CommandLineTool resolvedTool) else None
102+ ))
103+
104+ let graph1 = Builder.buildWith options processingUnit
105+ let graph2 = Builder.buildWith options processingUnit
106+
107+ let nodeIds1 = graph1.Nodes |> Seq.map ( fun n -> n.Id) |> Seq.sort |> Seq.toArray
108+ let nodeIds2 = graph2.Nodes |> Seq.map ( fun n -> n.Id) |> Seq.sort |> Seq.toArray
109+ let edgeIds1 = graph1.Edges |> Seq.map ( fun e -> e.Id) |> Seq.sort |> Seq.toArray
110+ let edgeIds2 = graph2.Edges |> Seq.map ( fun e -> e.Id) |> Seq.sort |> Seq.toArray
111+
112+ Expect.sequenceEqual nodeIds1 nodeIds2 " "
113+ Expect.sequenceEqual edgeIds1 edgeIds2 " "
114+
115+ testCase " buildWith does not mutate workflow step run payloads" <| fun () ->
116+ let yaml = """ cwlVersion: v1.2
117+ class: Workflow
118+ inputs: {}
119+ outputs: {}
120+ steps:
121+ step1:
122+ run: ./tool.cwl
123+ in: {}
124+ out: [out]"""
125+ let processingUnit = Decode.decodeCWLProcessingUnit yaml
126+ let resolvedTool = Decode.decodeCommandLineTool TestObjects.CWL.CommandLineTool.cwlFile
127+ let options =
128+ WorkflowGraphBuildOptions.defaultOptions
129+ |> WorkflowGraphBuildOptions.withRootWorkflowFilePath ( Some " workflow.cwl" )
130+ |> WorkflowGraphBuildOptions.withTryResolveRunPath ( Some ( fun path ->
131+ if path.EndsWith( " tool.cwl" ) then Some ( CommandLineTool resolvedTool) else None
132+ ))
133+
134+ let assertRunString () =
135+ match processingUnit with
136+ | Workflow wf ->
137+ match wf.Steps.[ 0 ]. Run with
138+ | RunString runPath -> Expect.equal runPath " ./tool.cwl" " "
139+ | other -> Expect.isTrue false $" Expected RunString but got %A {other}"
140+ | _ ->
141+ Expect.isTrue false " Expected workflow processing unit"
142+
143+ assertRunString ()
144+ let _graph = Builder.buildWith options processingUnit
145+ assertRunString ()
146+
85147 testCase " scatter fields do not break graph build and are preserved as metadata" <| fun () ->
86148 let graph = buildGraphFromYaml TestObjects.CWL.Workflow.workflowWithScatterAndScatterMethodFile
87149 let stepNodeOpt =
0 commit comments