This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new 4cac2b00a Fix output of info parser / info unparser in debug
4cac2b00a is described below
commit 4cac2b00acd71acc0a2a6ee89fbf1beb315eaf32
Author: Varun Zaver <[email protected]>
AuthorDate: Wed Jun 29 07:30:30 2022 -0500
Fix output of info parser / info unparser in debug
When the user is in debug mode with the subcommand parse, the ouput for
info unparser will now display correctly.
When the user is in debug mode with the subcommand unparse, the output
for info parser will now display correctly.
When the user is in debug mode while calling the parse or unparse
subcommand, we want to make sure that the info printed to the screen for
parser and unparser are accurate. This is done by comparing the
subcommand and the info argument. The "info parser" command prints the
parser information only when the parser subcommand is utilized. The "info
unparser" command prints the unparser information only when the unparse
subcommand is utilitzed.
DAFFODIL-2488
---
.../apache/daffodil/debugger/TestCLIDebugger.scala | 51 ++++++++++++++++++++++
.../daffodil/debugger/InteractiveDebugger.scala | 17 +++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git
a/daffodil-cli/src/it/scala/org/apache/daffodil/debugger/TestCLIDebugger.scala
b/daffodil-cli/src/it/scala/org/apache/daffodil/debugger/TestCLIDebugger.scala
index 5a208f662..4fd06fe8a 100644
---
a/daffodil-cli/src/it/scala/org/apache/daffodil/debugger/TestCLIDebugger.scala
+++
b/daffodil-cli/src/it/scala/org/apache/daffodil/debugger/TestCLIDebugger.scala
@@ -1440,5 +1440,56 @@ class TestCLIdebugger {
}
}
+ @Test def test_CLI_Debugger_parse_unparser_not_available(): Unit = {
+ val schemaFile =
Util.daffodilPath("daffodil-test/src/test/resources/org/apache/daffodil/section06/entities/charClassEntities.dfdl.xsd")
+ val inputFile =
Util.daffodilPath("daffodil-cli/src/it/resources/org/apache/daffodil/CLI/input/input3.txt")
+ val (testSchemaFile, testInputFile) = if (Util.isWindows)
(Util.cmdConvert(schemaFile), Util.cmdConvert(inputFile)) else (schemaFile,
inputFile)
+
+ val shell = if (Util.isWindows) Util.start("", envp = DAFFODIL_JAVA_OPTS)
else Util.start("")
+
+ try {
+ val cmd = String.format("%s -d parse -s %s %s", Util.binPath,
testSchemaFile, testInputFile)
+ shell.sendLine(cmd)
+ shell.expect(contains("(debug)"))
+
+ shell.sendLine("info parser")
+ shell.expect(contains("parser: <Element
name='matrix'><DelimiterStackParser>...</DelimiterStackParser></Element>"))
+
+ shell.sendLine("info unparser")
+ shell.expect(contains("unparser: not available"))
+
+ shell.sendLine("continue")
+
+ Util.expectExitCode(ExitCode.Success, shell)
+ } finally {
+ shell.close()
+ }
+ }
+
+ @Test def test_CLI_Debugger_unparse_parser_not_available(): Unit = {
+ val schemaFile =
Util.daffodilPath("daffodil-test/src/test/resources/org/apache/daffodil/section06/entities/charClassEntities.dfdl.xsd")
+ val inputFile =
Util.daffodilPath("daffodil-cli/src/it/resources/org/apache/daffodil/CLI/input/input1.txt.xml")
+ val (testSchemaFile, testInputFile) = if (Util.isWindows)
(Util.cmdConvert(schemaFile), Util.cmdConvert(inputFile)) else (schemaFile,
inputFile)
+
+ val shell = if (Util.isWindows) Util.start("", envp = DAFFODIL_JAVA_OPTS)
else Util.start("")
+
+ try {
+ val cmd = String.format("%s -d unparse -s %s %s", Util.binPath,
testSchemaFile, testInputFile)
+ shell.sendLine(cmd)
+ shell.expect(contains("(debug)"))
+
+ shell.sendLine("info unparser")
+ shell.expect(contains("unparser: <ConvertTextNumberUnparser/>"))
+
+ shell.sendLine("info parser")
+ shell.expect(contains("parser: not available"))
+
+ shell.sendLine("continue")
+
+ Util.expectExitCode(ExitCode.Success, shell)
+ } finally {
+ shell.close()
+ }
+ }
}
diff --git
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
index 47cef5626..474c87232 100644
---
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
+++
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
@@ -1595,7 +1595,22 @@ class InteractiveDebugger(runner:
InteractiveDebuggerRunner, eCompilers: Express
val desc = "display the current Daffodil " + name
val longDesc = desc
def act(args: Seq[String], state: ParseOrUnparseState, processor:
Processor): DebugState.Type = {
- debugPrintln("%s: %s".format(name, processor.toBriefXML(2))) // only
2 levels of output, please!
+ state match {
+ case pstate: PState => {
+ if (name == "parser") {
+ debugPrintln("%s: %s".format(name, processor.toBriefXML(2)))
+ } else {
+ debugPrintln("unparser: not available")
+ }
+ }
+ case ustate: UState => {
+ if (name == "unparser") {
+ debugPrintln("%s: %s".format(name, processor.toBriefXML(2)))
+ } else {
+ debugPrintln("parser: not available")
+ }
+ }
+ }
DebugState.Pause
}
}