Skip to content

Commit

Permalink
have something that works for stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Jan 12, 2025
1 parent 4a07970 commit e834e9f
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 27 deletions.
89 changes: 77 additions & 12 deletions tested/dsl/schema-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,27 @@
},
"stdin" : {
"description" : "Stdin for this context",
"type" : [
"string",
"number",
"integer",
"boolean"
"oneOf": [
{
"type" : [
"string",
"number",
"integer",
"boolean"
]
},
{
"type": "object",
"required" : [
"path"
],
"properties" : {
"path": {
"type": "string",
"description": "Path to the file that contains the stdin"
}
}
}
]
},
"arguments" : {
Expand Down Expand Up @@ -372,11 +388,27 @@
},
"stdin" : {
"description" : "Stdin for this context",
"type" : [
"string",
"number",
"integer",
"boolean"
"oneOf": [
{
"type" : [
"string",
"number",
"integer",
"boolean"
]
},
{
"type": "object",
"required" : [
"path"
],
"properties" : {
"path": {
"type": "string",
"description": "Path to the file that contains the stdin"
}
}
}
]
},
"arguments" : {
Expand Down Expand Up @@ -519,10 +551,23 @@
{
"type" : "object",
"description" : "Built-in oracle for text values.",
"required" : [
"data"
"oneOf": [
{
"required" : [
"data"
]
},
{
"required" : [
"path"
]
}
],
"properties" : {
"path": {
"type" : "string",
"description" : "The path to the file containing the text value."
},
"data" : {
"$ref" : "#/definitions/textualType"
},
Expand All @@ -537,12 +582,32 @@
{
"type" : "object",
"description" : "Custom oracle for text values.",
"oneOf": [
{
"required" : [
"oracle",
"file",
"data"
]
},
{
"required" : [
"oracle",
"file",
"path"
]
}
],
"required" : [
"oracle",
"file",
"data"
],
"properties" : {
"path": {
"type" : "string",
"description" : "The path to the file containing the text value."
},
"data" : {
"$ref" : "#/definitions/textualType"
},
Expand Down
89 changes: 77 additions & 12 deletions tested/dsl/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,27 @@
},
"stdin" : {
"description" : "Stdin for this context",
"type" : [
"string",
"number",
"integer",
"boolean"
"oneOf": [
{
"type" : [
"string",
"number",
"integer",
"boolean"
]
},
{
"type": "object",
"required" : [
"path"
],
"properties" : {
"path": {
"type": "string",
"description": "Path to the file that contains the stdin"
}
}
}
]
},
"arguments" : {
Expand Down Expand Up @@ -372,11 +388,27 @@
},
"stdin" : {
"description" : "Stdin for this context",
"type" : [
"string",
"number",
"integer",
"boolean"
"oneOf": [
{
"type" : [
"string",
"number",
"integer",
"boolean"
]
},
{
"type": "object",
"required" : [
"path"
],
"properties" : {
"path": {
"type": "string",
"description": "Path to the file that contains the stdin"
}
}
}
]
},
"arguments" : {
Expand Down Expand Up @@ -519,10 +551,23 @@
{
"type" : "object",
"description" : "Built-in oracle for text values.",
"required" : [
"data"
"oneOf": [
{
"required" : [
"data"
]
},
{
"required" : [
"path"
]
}
],
"properties" : {
"path": {
"type" : "string",
"description" : "The path to the file containing the text value."
},
"data" : {
"$ref" : "#/definitions/textualType"
},
Expand All @@ -537,12 +582,32 @@
{
"type" : "object",
"description" : "Custom oracle for text values.",
"oneOf": [
{
"required" : [
"oracle",
"file",
"data"
]
},
{
"required" : [
"oracle",
"file",
"path"
]
}
],
"required" : [
"oracle",
"file",
"data"
],
"properties" : {
"path": {
"type" : "string",
"description" : "The path to the file containing the text value."
},
"data" : {
"$ref" : "#/definitions/textualType"
},
Expand Down
10 changes: 7 additions & 3 deletions tested/dsl/translate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
TextBuiltin,
TextData,
TextOutputChannel,
ValueOutputChannel,
ValueOutputChannel, TextChannelType,
)
from tested.utils import get_args, recursive_dict_merge

Expand Down Expand Up @@ -590,8 +590,12 @@ def _convert_testcase(testcase: YamlDict, context: DslContext) -> Testcase:
return_channel = IgnoredChannel.IGNORED if "statement" in testcase else None
else:
if "stdin" in testcase:
assert isinstance(testcase["stdin"], str)
stdin = TextData(data=_ensure_trailing_newline(testcase["stdin"]))
if isinstance(testcase["stdin"], dict):
path = testcase["stdin"].get("path")
stdin = TextData(data=path, type=TextChannelType.FILE)
else:
assert isinstance(testcase["stdin"], str)
stdin = TextData(data=_ensure_trailing_newline(testcase["stdin"]))
else:
stdin = EmptyChannel.NONE
arguments = testcase.get("arguments", [])
Expand Down

0 comments on commit e834e9f

Please sign in to comment.