Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Tests for primitive types and "type coercion" part of WDL specification #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def test_identity_coercions(workflow_runner):
"""
Identity coercions
"""

test_file_name = "test.file"
test_file_content = "test content"
test_string = "test string"
test_int = 12345
test_float = 123.123
test_boolean = False
test_array = [1, 2, 3, 4, 5]
test_map = {"1": "one", "2": "two", "3": "three"}

inputs = {"wf_in_file_name": test_file_name,
"wf_in_file_content": test_file_content,
"in_string": test_string,
"in_int": test_int,
"in_float": test_float,
"in_boolean": test_boolean,
"in_array": test_array,
"in_map": test_map}

expectations = {"out_file_content": test_file_content,
"out_string": test_string,
"out_int": test_int,
"out_float": test_float,
"out_boolean": test_boolean,
"out_array": test_array,
"out_map": test_map}

workflow_runner("test_identity_coercions.wdl", inputs, expectations)
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version 1.0

workflow test_identity_coercions {
input {
String wf_in_file_name
String wf_in_file_content

String in_string
Int in_int
Float in_float
Boolean in_boolean
Array[Int] in_array
Map[Int, String] in_map
}

String string = in_string
Int int = in_int
Float float = in_float
Boolean boolean = in_boolean
Array[Int] array = in_array
Map[String, String] map = in_map
grsterin marked this conversation as resolved.
Show resolved Hide resolved

call create_file { input: in_file_name = wf_in_file_name, in_file_content = wf_in_file_content }
File file = create_file.out_file

output {
String out_file_content = read_string(file)
String out_string = string
Int out_int = int
Float out_float = float
Boolean out_boolean = boolean
Array[Int] out_array = array
Map[String, String] out_map = map
}
}

task create_file {
runtime {
docker: "ubuntu:latest"
}

input {
String in_file_name
String in_file_content
}

command <<<
echo ~{in_file_content} > ~{in_file_name}
>>>

output {
File out_file = in_file_name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def test_non_integer_jsnum_to_int_coercion(workflow_runner):
"""
Float and Int coercions
"""

test_jsnum = 123.123
expected_num = 123

inputs = {"in_int": test_jsnum}

expectations = {"out_int": expected_num}

workflow_runner("test_non_integer_jsnum_to_int_coercion.wdl", inputs, expectations)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version 1.0

workflow test_non_integer_jsnum_to_int_coercion {
input {
Int in_int
}

output {
Int out_int = in_int
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def test_file2string_and_string2file_coercions(workflow_runner):
"""
String-to-File and File-to-String type coercions
"""

test_file_name = "test.file"
test_file_content = "test content"

inputs = {"wf_in_file_name": test_file_name, "wf_in_file_content": test_file_content}
expectations = {"out_str_coerced_from_file": test_file_name, "out_content_of_file_coerced_from_string": test_file_content}

workflow_runner("test_file2string_and_string2file_coercions.wdl", inputs, expectations)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version 1.0

workflow test_file2string_and_string2file_coercions {
input {
String wf_in_file_name
String wf_in_file_content
}

call create_file { input: in_file_name = wf_in_file_name, in_file_content = wf_in_file_content }

String str_coerced_from_file = create_file.out_file # File to String
File file_coerced_from_str = str_coerced_from_file # String to File

output {
String out_str_coerced_from_file = sub(str_coerced_from_file, "^/(.+/)", "")
grsterin marked this conversation as resolved.
Show resolved Hide resolved
String out_content_of_file_coerced_from_string = read_string(file_coerced_from_str)
}
}

task create_file {
runtime {
docker: "ubuntu:latest"
}

input {
String in_file_name
String in_file_content
}

command <<<
echo ~{in_file_content} > ~{in_file_name}
>>>

output {
File out_file = in_file_name
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def test_primitive_types(workflow_runner):
"""
All primitive types from the specification are supported
Composite types and type coercion are out of this test's scope
"""
workflow_runner("test_primitive_types.wdl")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version 1.0

workflow test_types_wf {
Int i = 0 # An integer value
Float float = 27.3 # A floating point number
Boolean bool = true # A boolean true
Boolean bool2 = false # A boolean false
String str = "hello, $!~ \n\t\r world" # A string value
grsterin marked this conversation as resolved.
Show resolved Hide resolved
File file = "/dev/null" # A file
}