-
Notifications
You must be signed in to change notification settings - Fork 11
Testing of object, map, and array literals #8
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
__pycache__ | ||
.DS_Store | ||
|
||
# cromwell jar files | ||
# cromwell jar files, etc. | ||
cromwell-executions | ||
cromwell-workflow-logs | ||
*.jar | ||
pytest-wdl-tests/tests/literals/run.sh | ||
pytest-wdl-tests/tests/literals/validate.sh | ||
pytest-wdl-tests/tests/literals/json.sh | ||
|
||
# python virtual environment | ||
env/ | ||
env/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
INTS | ||
0 | ||
1 | ||
2 | ||
STRINGS | ||
array | ||
literal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
INTS | ||
1 10 | ||
2 11 | ||
MIXED | ||
a 1 | ||
b 2 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
a b | ||
10 11 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
OBJECT_SYNTAX | ||
key1 key2 key3 | ||
7 8 9 | ||
MAP_COERCION | ||
key1name key2name key3name | ||
10 11 12 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
23 twenty-three |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# This workflow tests the the literals sections of the WDL 1.0 Spec | ||
# It also requires the use of some functions such as write_lines(), write_object(), write_map(), and stdout() | ||
# write_map() is slightly broken as it does not print a \n after writing like the related functions do. | ||
|
||
version 1.0 | ||
|
||
workflow literals { | ||
input { | ||
### Array Literals | ||
Array[String] array_literal_strings = ["array", "literal"] | ||
Array[Int] array_literal_ints = [0, 1, 2] | ||
|
||
### Map Literals | ||
Map[Int, Int] map_literal_ints = {1: 10, 2: 11} | ||
Map[String, Int] map_literal_mixed = {"a": 1, "b": 2} | ||
|
||
### Object Literals | ||
Object object_literal = object { | ||
a: 10, | ||
b: 11 | ||
} | ||
|
||
### Object Coercion from Map | ||
# "object" keyword before {} indicates Object, absence of indicates Map. | ||
String key1 = "key1name" | ||
String key2 = "key2name" | ||
String key3 = "key3name" | ||
|
||
Object object_syntax = object { | ||
key1: 7, | ||
key2: 8, | ||
key3: 9 | ||
} | ||
|
||
Object map_coercion = { | ||
key1: 10, | ||
key2: 11, | ||
key3: 12 | ||
} | ||
|
||
### Pair Literals | ||
Pair[Int, String] pair_literal_mixed = (23, "twenty-three") | ||
} | ||
call array_literals { | ||
input: | ||
array_literal_strings=write_lines(array_literal_strings), | ||
array_literal_ints=write_lines(array_literal_ints) | ||
} | ||
call map_literals { | ||
input: | ||
map_literal_ints=write_map(map_literal_ints), | ||
map_literal_mixed=write_map(map_literal_mixed) | ||
} | ||
call object_literals { | ||
input: | ||
object_literal = write_object(object_literal) | ||
} | ||
call object_map_coercion { | ||
input: | ||
object_syntax=write_object(object_syntax), | ||
map_coercion=write_object(map_coercion) | ||
} | ||
call pair_literals { | ||
input: | ||
pair_literal_mixed_left=pair_literal_mixed.left, | ||
pair_literal_mixed_right=pair_literal_mixed.right | ||
} | ||
output { | ||
File array_literals_out = array_literals.array_literals_out | ||
File map_literals_out = map_literals.map_literals_out | ||
File object_literals_out = object_literals.object_literals_out | ||
File object_map_coercion_out = object_map_coercion.object_map_coercion_out | ||
File pair_literals_out = pair_literals.pair_literals_out | ||
} | ||
} | ||
|
||
task array_literals { | ||
input { | ||
File array_literal_ints | ||
File array_literal_strings | ||
} | ||
command { | ||
set -e | ||
echo INTS | ||
cat ~{array_literal_ints} | ||
printf "STRINGS\n" | ||
cat ~{array_literal_strings} | ||
} | ||
output { | ||
File array_literals_out = stdout() | ||
} | ||
} | ||
|
||
task map_literals { | ||
input { | ||
File map_literal_ints | ||
File map_literal_mixed | ||
} | ||
command { | ||
set -e | ||
|
||
echo INTS | ||
cat ~{map_literal_ints} | ||
printf "\nMIXED\n" | ||
cat ~{map_literal_mixed} | ||
} | ||
output { | ||
File map_literals_out = stdout() | ||
} | ||
} | ||
|
||
task object_literals { | ||
input { | ||
File object_literal | ||
} | ||
command { | ||
set -e | ||
|
||
cat ~{object_literal} | ||
} | ||
output { | ||
File object_literals_out = stdout() | ||
} | ||
} | ||
|
||
task object_map_coercion { | ||
input { | ||
File object_syntax | ||
File map_coercion | ||
} | ||
command { | ||
set -e | ||
|
||
echo OBJECT_SYNTAX | ||
cat ~{object_syntax} | ||
printf "MAP_COERCION\n" | ||
cat ~{map_coercion} | ||
} | ||
output { | ||
File object_map_coercion_out = stdout() | ||
} | ||
} | ||
|
||
task pair_literals { | ||
input { | ||
Int pair_literal_mixed_left | ||
String pair_literal_mixed_right | ||
} | ||
command { | ||
set -e | ||
|
||
echo ~{pair_literal_mixed_left} ~{pair_literal_mixed_right} | ||
} | ||
output { | ||
File pair_literals_out = stdout() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need this if the file is empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I deleted the jsons and the input dictionaries from every line in the python script and it gave me that error message. Any way around supplying inputs to py-test wdl? |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def test_literals(workflow_data, workflow_runner): | ||
inputs = {} | ||
expected = workflow_data.get_dict("array_literals_out", "map_literals_out", "object_literals_out", "object_map_coercion_out", "pair_literals_out") | ||
workflow_runner("literals.wdl", inputs, expected, workflow_name="literals") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
I am a document. I am all spaces. Let me pass! | ||
Look now I'm in this python heredoc! I am a document. I am all spaces. Let me pass! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
I am a document. I am all tabs. Let me pass! | ||
Look now I'm in this python heredoc! I am a document. I am all tabs. Let me pass! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow has tab indents and one extra indent at the heredoc! It is intended to fail miserably. | ||
|
||
version 1.0 | ||
|
||
workflow indented_heredoc { | ||
input { | ||
String message = "I am a document. I am indented incorrectly at the heredoc. Let me fail!" | ||
} | ||
call t { | ||
input: message=message | ||
} | ||
output { | ||
File indented_heredoc_out = t.out | ||
} | ||
} | ||
|
||
task t { | ||
input { | ||
String message | ||
} | ||
command { | ||
echo ~{message} | ||
python <<CODE | ||
for i in range(0,1): | ||
print("Look now I'm in this python heredoc! ~{message}") | ||
CODE | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow has 2-space indents and one tab at the heredoc! It is intended to fail miserably. | ||
|
||
version 1.0 | ||
|
||
workflow mixed { | ||
input { | ||
String message = "I am a document. I am mixed. Let me fail!" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? This looks fine to me? If I'm reading this right: The engine will strip the common spacing from the start of the command section, and then the python heredoc will have a single tab indentation in it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I get this error message, I believe it fails because of the tab in the heredoc |
||
} | ||
call t { | ||
input: message=message | ||
} | ||
output { | ||
File mixed_out = t.out | ||
} | ||
} | ||
|
||
task t { | ||
input { | ||
String message | ||
} | ||
command { | ||
echo ~{message} | ||
python <<CODE | ||
for i in range(0,1): | ||
print("Look now I'm in this python heredoc! ~{message}") | ||
CODE | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This main workflow is all tab-indented, but it calls both a tab-indented and a 2-space indented subworkflow. | ||
# It is intended to run successfully. | ||
|
||
version 1.0 | ||
|
||
import "tabs.wdl" as t | ||
import "spaces.wdl" as s | ||
|
||
workflow proper_whitespace { | ||
call t.tabs as tabs | ||
call s.spaces as spaces | ||
output { | ||
File tabs_out = tabs.tabs_out | ||
File spaces_out = spaces.spaces_out | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow is all 2-space-indented, it is intended to run successfully. | ||
|
||
version 1.0 | ||
|
||
workflow spaces { | ||
input { | ||
String message = "I am a document. I am all spaces. Let me pass!" | ||
} | ||
call t { | ||
input: message=message | ||
} | ||
output { | ||
File spaces_out = t.out | ||
} | ||
} | ||
|
||
task t { | ||
input { | ||
String message | ||
} | ||
command { | ||
echo ~{message} | ||
python <<CODE | ||
for i in range(0,1): | ||
print("Look now I'm in this python heredoc! ~{message}") | ||
CODE | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow is all tab-indented, it is intended to run successfully. | ||
|
||
version 1.0 | ||
|
||
workflow tabs { | ||
input { | ||
String message = "I am a document. I am all tabs. Let me pass!" | ||
} | ||
call t { | ||
input: message=message | ||
} | ||
output { | ||
File tabs_out = t.out | ||
} | ||
} | ||
|
||
task t { | ||
input { | ||
String message | ||
} | ||
command { | ||
echo ~{message} | ||
python <<CODE | ||
for i in range(0,1): | ||
print("Look now I'm in this python heredoc! ~{message}") | ||
CODE | ||
} | ||
output { | ||
File out = stdout() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you decided that you wanted to assert that there would be a newline added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the newline in that WDL command so that Cromwell output would match this output file. If you're referring to lack of new line at the end of file, I don't know what's right, I just wanted write_map() to give a similar format to array's write_lines()