Skip to content

Commit

Permalink
rename types and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caroott authored and kMutagene committed Oct 21, 2024
1 parent 83cad3e commit f452622
Show file tree
Hide file tree
Showing 23 changed files with 245 additions and 226 deletions.
4 changes: 2 additions & 2 deletions src/ARCtrl/ARC.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module ARCAux =
|> FileSystem.create
fs.Union(tree)

let updateFSByCWL (cwl : CWL.CWLProcessingUnits.CWLToolDescription option) (fs : FileSystem) =
let updateFSByCWL (cwl : unit option) (fs : FileSystem) =
let workflows = FileSystemTree.createWorkflowsFolder [||]
let runs = FileSystemTree.createRunsFolder [||]
let tree =
Expand All @@ -65,7 +65,7 @@ module ARCAux =


[<AttachMembers>]
type ARC(?isa : ArcInvestigation, ?cwl : CWL.CWLProcessingUnits.CWLToolDescription, ?fs : FileSystem.FileSystem) =
type ARC(?isa : ArcInvestigation, ?cwl : unit, ?fs : FileSystem.FileSystem) =

let mutable _isa = isa
let mutable _cwl = cwl
Expand Down
3 changes: 0 additions & 3 deletions src/CWL/ARCtrl.CWL.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
<Compile Include="Decode.fs" />
<Compile Include="Encode.fs" />
</ItemGroup>
<ItemGroup>
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="YAMLicious"/>
<PackageReference Include="DynamicObj"/>
Expand Down
11 changes: 6 additions & 5 deletions src/CWL/CWL.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ARCtrl.CWL
namespace ARCtrl

open ARCtrl.CWL
open DynamicObj
open CWLTypes
open Requirements
Expand All @@ -11,7 +12,7 @@ module CWLProcessingUnits =

type CWLToolDescription (
cwlVersion: string,
cls: Class,
cls: CWLClass,
outputs: Output [],
?baseCommand: string [],
?requirements: Requirement [],
Expand All @@ -22,7 +23,7 @@ module CWLProcessingUnits =
inherit DynamicObj ()

let mutable _cwlVersion: string = cwlVersion
let mutable _class: Class = cls
let mutable _class: CWLClass = cls
let mutable _outputs: Output [] = outputs
let mutable _baseCommand: string [] option = baseCommand
let mutable _requirements: Requirement [] option = requirements
Expand Down Expand Up @@ -64,7 +65,7 @@ module CWLProcessingUnits =

type CWLWorkflowDescription(
cwlVersion: string,
cls: Class,
cls: CWLClass,
steps: WorkflowStep [],
inputs: Input [],
outputs: Output [],
Expand All @@ -75,7 +76,7 @@ module CWLProcessingUnits =
inherit DynamicObj()

let mutable _cwlVersion: string = cwlVersion
let mutable _class: Class = cls
let mutable _class: CWLClass = cls
let mutable _steps: WorkflowStep [] = steps
let mutable _inputs: Input [] = inputs
let mutable _outputs: Output [] = outputs
Expand Down
2 changes: 1 addition & 1 deletion src/CWL/CWLTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module CWLTypes =
| Null
| Array of CWLType

type Class =
type CWLClass =
| Workflow
| CommandLineTool
| ExpressionTool
Expand Down
3 changes: 2 additions & 1 deletion src/CWL/Decode.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ARCtrl.CWL

open ARCtrl
open YAMLicious
open YAMLicious.YAMLiciousTypes
open CWLTypes
Expand Down Expand Up @@ -317,7 +318,7 @@ module Decode =
let versionDecoder: (YAMLiciousTypes.YAMLElement -> string) =
Decode.object (fun get -> get.Required.Field "cwlVersion" Decode.string)

let classDecoder: (YAMLiciousTypes.YAMLElement -> Class) =
let classDecoder: (YAMLiciousTypes.YAMLElement -> CWLClass) =
Decode.object (fun get ->
match get.Required.Field "class" Decode.string with
| "Workflow" -> Workflow
Expand Down
1 change: 0 additions & 1 deletion tests/CWL/ARCtrl.CWL.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<ItemGroup>
<Compile Include="CWLWorkflow.Tests.fs" />
<Compile Include="CWLObject.Tests.fs" />
<Compile Include="CWLObjectMetadata.Tests.fs" />
<Compile Include="Metadata.Tests.fs" />
<Compile Include="Outputs.Tests.fs" />
<Compile Include="Inputs.Tests.fs" />
Expand Down
179 changes: 175 additions & 4 deletions tests/CWL/CWLObject.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ open ARCtrl.CWL.CWLTypes
open ARCtrl.CWL.Requirements
open ARCtrl.CWL.Inputs
open ARCtrl.CWL.Outputs
open YAMLicious
open TestingUtils
open DynamicObj

let decodeCWLToolDescription =
TestObjects.CWL.CommandLineTool.cwl
TestObjects.CWL.CommandLineTool.cwlFile
|> Decode.decodeCommandLineTool

let decodeCWLToolDescriptionMetadata =
TestObjects.CWL.CommandLineToolMetadata.cwlFile
|> Decode.decodeCommandLineTool


let testCWLToolDescription =
testList "CWLToolDescription" [
testList "Decode" [
testCase "Class" <| fun _ ->
let expected = Class.CommandLineTool
let expected = CWLClass.CommandLineTool
let actual = decodeCWLToolDescription.Class
Expect.isTrue
(expected = actual)
Expand Down Expand Up @@ -170,4 +175,170 @@ let testCWLToolDescription =
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]

let testCWLToolDescriptionMetadata =
testList "Decode with Metadata" [
testCase "Class" <| fun _ ->
let expected = CWLClass.CommandLineTool
let actual = decodeCWLToolDescriptionMetadata.Class
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "CWLVersion" <| fun _ ->
let expected = "v1.2"
let actual = decodeCWLToolDescriptionMetadata.CWLVersion
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "baseCommand" <| fun _ ->
let expected = Some [|"dotnet"; "fsi"; "script.fsx"|]
let actual = decodeCWLToolDescriptionMetadata.BaseCommand
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testList "Hints" [
let hintsItem = decodeCWLToolDescriptionMetadata.Hints
testCase "DockerRequirement" <| fun _ ->
let expected = DockerRequirement {DockerPull = Some "mcr.microsoft.com/dotnet/sdk:6.0"; DockerFile = None; DockerImageId = None}
let actual = hintsItem.Value.[0]
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]
testList "Requirements" [
let requirementsItem = decodeCWLToolDescriptionMetadata.Requirements
testCase "InitialWorkDirRequirement" <| fun _ ->
let expected = InitialWorkDirRequirement [|Dirent {Entry = "$include: script.fsx"; Entryname = Some "script.fsx"; Writable = None }|]
let actual = requirementsItem.Value.[0]
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "EnvVarRequirement" <| fun _ ->
let expected = EnvVarRequirement [|{EnvName = "DOTNET_NOLOGO"; EnvValue = "true"}|]
let actual = requirementsItem.Value.[1]
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "NetworkAccessRequirement" <| fun _ ->
let expected = NetworkAccessRequirement
let actual = requirementsItem.Value.[2]
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]
testList "Inputs" [
let inputsItem = decodeCWLToolDescriptionMetadata.Inputs.Value
testCase "Length" <| fun _ ->
let expected = 2
let actual = inputsItem.Length
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testList "File" [
let fileItem = inputsItem.[0]
testCase "Name" <| fun _ ->
let expected = "firstArg"
let actual = fileItem.Name
Expect.isTrue
("firstArg" = fileItem.Name)
"Name of input is not 'firstArg'"
testCase "Type" <| fun _ ->
let expected = File (FileInstance())
let actual = fileItem.Type_.Value
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "InputBinding" <| fun _ ->
let expected = Some {Position = Some 1; Prefix = None; ItemSeparator = None; Separate = None}
let actual = fileItem.InputBinding
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]
testList "String" [
let stringItem = inputsItem.[1]
testCase "Name" <| fun _ ->
let expected = "secondArg"
let actual = stringItem.Name
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "Type" <| fun _ ->
let expected = String
let actual = stringItem.Type_.Value
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "InputBinding" <| fun _ ->
let expected = Some {Position = Some 2; Prefix = None; ItemSeparator = None; Separate = None}
let actual = stringItem.InputBinding
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]
]
testList "Outputs" [
let outputsItem = decodeCWLToolDescriptionMetadata.Outputs
testCase "Length" <| fun _ ->
let expected = 2
let actual = outputsItem.Length
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testList "Directory" [
let directoryItem = outputsItem.[0]
testCase "Name" <| fun _ ->
let expected = "output"
let actual = directoryItem.Name
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "Type" <| fun _ ->
let expected = Directory (DirectoryInstance())
let actual = directoryItem.Type_.Value
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "OutputBinding" <| fun _ ->
let expected = Some {Glob = Some "$(runtime.outdir)/.nuget"}
let actual = directoryItem.OutputBinding
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]
testList "File" [
let fileItem = outputsItem.[1]
testCase "Name" <| fun _ ->
let expected = "output2"
let actual = fileItem.Name
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "Type" <| fun _ ->
let expected = File (FileInstance())
let actual = fileItem.Type_.Value
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
testCase "OutputBinding" <| fun _ ->
let expected = Some {Glob = Some "$(runtime.outdir)/*.csv"}
let actual = fileItem.OutputBinding
Expect.isTrue
(expected = actual)
$"Expected: {expected}\nActual: {actual}"
]
]
testCase "Metadata" <| fun _ ->
Expect.isSome decodeCWLToolDescriptionMetadata.Metadata $"Expected {decodeCWLToolDescriptionMetadata.Metadata} to be Some"
let expected = TestObjects.CWL.CommandLineToolMetadata.expectedMetadataString.Trim().Replace("\r\n", "\n")
let actual = (decodeCWLToolDescriptionMetadata.Metadata.Value |> DynObj.format).Trim().Replace("\r\n", "\n")
Expect.equal actual expected
$"Expected: {expected}\nActual: {actual}"
]

let main =
testList "CWLToolDescription" [
testCWLToolDescription
testCWLToolDescriptionMetadata
]
Loading

0 comments on commit f452622

Please sign in to comment.