diff --git a/tests/test_map_serialization/main.wdl b/tests/test_map_serialization/main.wdl new file mode 100644 index 0000000..68d45e9 --- /dev/null +++ b/tests/test_map_serialization/main.wdl @@ -0,0 +1,21 @@ +version 1.0 +import "map_task.wdl" as map_wdl + +workflow wf { + call map_wdl.make_test_cases as mk + Map[File, Int] map_int = {mk.files[0]: 1, mk.files[1]: 2, mk.files[2]: 3} + Map[File, Boolean] map_bool = {mk.files[0]: true, mk.files[1]: false, mk.files[2]: false} + + call map_wdl.write_map as write_map { + input: + map_of_ints = map_int, + map_of_booleans = map_bool + } + + call map_wdl.read_map + + output { + File out_file_int = write_map.out1 + File out_file_bool = write_map.out2 + } +} diff --git a/tests/test_map_serialization/map_task.wdl b/tests/test_map_serialization/map_task.wdl new file mode 100644 index 0000000..8647a79 --- /dev/null +++ b/tests/test_map_serialization/map_task.wdl @@ -0,0 +1,48 @@ +version 1.0 + +task make_test_cases { + command { + } + output { + Array[String] files = ["f1", "f2", "f3"] + } + runtime { + docker: "python:3-slim" + } +} + +task write_map { + input { + Map[String, Int] map_of_ints + Map[String, Boolean] map_of_booleans + # output files for each map type tests + String out_file_two = "./output_map_of_ints.txt" + String out_file_three = "./output_map_of_bools.txt" + } + command { + cat ${write_map(map_of_ints)} > ~{out_file_two} + cat ${write_map(map_of_booleans)} > ~{out_file_three} + } + output { + File out1 = out_file_two + File out2 = out_file_three + } + runtime { + docker: "python:3-slim" + } +} + +task read_map { + command <<< + python3 <>> + output { + Map[String, Int] out_map = read_map(stdout()) + } + runtime { + docker: "python:3-slim" + } +} diff --git a/tests/test_map_serialization/tests/data/output_file_to_name.txt b/tests/test_map_serialization/tests/data/output_file_to_name.txt new file mode 100644 index 0000000..3a46903 --- /dev/null +++ b/tests/test_map_serialization/tests/data/output_file_to_name.txt @@ -0,0 +1,3 @@ +f1 alice +f2 bob +f3 chuck \ No newline at end of file diff --git a/tests/test_map_serialization/tests/data/output_map_of_bools.txt b/tests/test_map_serialization/tests/data/output_map_of_bools.txt new file mode 100644 index 0000000..2264cdf --- /dev/null +++ b/tests/test_map_serialization/tests/data/output_map_of_bools.txt @@ -0,0 +1,3 @@ +f1 true +f2 false +f3 false \ No newline at end of file diff --git a/tests/test_map_serialization/tests/data/output_map_of_ints.txt b/tests/test_map_serialization/tests/data/output_map_of_ints.txt new file mode 100644 index 0000000..8aae61c --- /dev/null +++ b/tests/test_map_serialization/tests/data/output_map_of_ints.txt @@ -0,0 +1,3 @@ +f1 1 +f2 2 +f3 3 \ No newline at end of file diff --git a/tests/test_map_serialization/tests/data/output_workflow/wf/6a55f93e-929c-4f5c-ba08-126618145d36/call-write_map/execution/output_map_of_bools.txt b/tests/test_map_serialization/tests/data/output_workflow/wf/6a55f93e-929c-4f5c-ba08-126618145d36/call-write_map/execution/output_map_of_bools.txt new file mode 100644 index 0000000..2264cdf --- /dev/null +++ b/tests/test_map_serialization/tests/data/output_workflow/wf/6a55f93e-929c-4f5c-ba08-126618145d36/call-write_map/execution/output_map_of_bools.txt @@ -0,0 +1,3 @@ +f1 true +f2 false +f3 false \ No newline at end of file diff --git a/tests/test_map_serialization/tests/data/output_workflow/wf/6a55f93e-929c-4f5c-ba08-126618145d36/call-write_map/execution/output_map_of_ints.txt b/tests/test_map_serialization/tests/data/output_workflow/wf/6a55f93e-929c-4f5c-ba08-126618145d36/call-write_map/execution/output_map_of_ints.txt new file mode 100644 index 0000000..8aae61c --- /dev/null +++ b/tests/test_map_serialization/tests/data/output_workflow/wf/6a55f93e-929c-4f5c-ba08-126618145d36/call-write_map/execution/output_map_of_ints.txt @@ -0,0 +1,3 @@ +f1 1 +f2 2 +f3 3 \ No newline at end of file diff --git a/tests/test_map_serialization/tests/test_data.json b/tests/test_map_serialization/tests/test_data.json new file mode 100644 index 0000000..66b5f93 --- /dev/null +++ b/tests/test_map_serialization/tests/test_data.json @@ -0,0 +1,8 @@ +{ + "out_file_int": { + "name": "output_map_of_ints.txt" + }, + "out_file_bool": { + "name": "output_map_of_bools.txt" + } +} \ No newline at end of file diff --git a/tests/test_map_serialization/tests/test_map_serialization.py b/tests/test_map_serialization/tests/test_map_serialization.py new file mode 100644 index 0000000..25ed656 --- /dev/null +++ b/tests/test_map_serialization/tests/test_map_serialization.py @@ -0,0 +1,10 @@ +def test_map_literal(workflow_data, workflow_runner): + expected = workflow_data.get_dict("out_file_int", "out_file_bool") + input={} + workflow_runner( + "../main.wdl", + input, + expected, + workflow_name="wf", + ) + diff --git a/tests/test_map_serialization/workflow_options.json b/tests/test_map_serialization/workflow_options.json new file mode 100644 index 0000000..112c651 --- /dev/null +++ b/tests/test_map_serialization/workflow_options.json @@ -0,0 +1,3 @@ +{ + "final_workflow_outputs_dir": "./tests/test_map_serialization/tests/data/output_workflow" +} \ No newline at end of file