Skip to content

Conversation

@johan-andruejol
Copy link
Contributor

Following the concerns raised in the Slicer's #576 (Slicer/Slicer#576), this addresses:

  • Multiple argument bug
  • Quote escaping issue

This also adds more testing and factorizes some of the testing infrastructure to be more easily extendable.

@jcfr, @thewtex: PTAL

@jcfr jcfr changed the title Fix deserialazation multiple args Fix deserialization multiple args Sep 2, 2016
@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

FixDeserialazation -> FixDeserialization

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

could you specify in the title of the commit that it is realated to the param serializer. E.g:

ENH: ParamSerializer: Use the longflag in priority
...

{
w | " if (parameters[\"" + groupLabel + "\"][\"" + parameterName + "\"].asBool())"
| " {"
| " deserializedVectorFlaggedArgs.push_back(\"" + flag + "\");"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deserialazation -> deserialization

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you write

Multiple arguments can either be flagged or positional

do you mean

Argument described using "multiple=true" can either be flagged or positional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an multiple argument is present ...

->

Argument described using "multiple=true" are found in both JSON and in the command line, similarly to other arguments, the values of the JSON are ignored.

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

Tests are failing with

13: Test command: /usr/bin/cmake "-DTEST_SOURCE_DIR:PATH=/usr/src/SlicerExecutionModel/GenerateCLP/Testing/CLPTestMultiple" "-DTEST_BINARY_DIR:PATH=/usr/src/SlicerExecutionModel-build/GenerateCLP/Testing/CLPTestMultiple" "-DTEST_CONFIGURATION:STRING=Release" "-P" "/usr/src/SlicerExecutionModel/GenerateCLP/Testing/CMake/GenerateCLPTest-Configure.cmake"
13: Test timeout computed to be: 1500
13: CMake Error at /usr/src/SlicerExecutionModel/GenerateCLP/Testing/CMake/GenerateCLPTestMacros.cmake:20 (cmake_parse_arguments):
13:   Unknown CMake command "cmake_parse_arguments".
13: Call Stack (most recent call first):
13:   CMakeLists.txt:4 (GenerateCLP_TEST_PROJECT_MACRO)
13: 
13: 
13: CMake Error at /usr/src/SlicerExecutionModel/GenerateCLP/Testing/CMake/GenerateCLPTest-Configure.cmake:43 (message):
13:   Failed to configure Test:
13: 
13:   -- The C compiler identification is GNU 4.9.2
13: 

@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

Nice work overall 👍

After fixing the remaining issues, we should be in good shape

The longflag has a higher priority over the flag.
…alization

The code wasn't handling multiple parameters correctly and crashing when
trying to deserialize arrays of arrays. This commit addresses that.

Arguments using "multiple=true" can either be flagged or positional.
 - When they are positional, they must be the last argument of the CLI. In
this case, the infrastructure already handles this.
 - When they are flagged, we need to detect that the argument allows for
multiple flag/value pairs. To do so, we introduce the map called
deserializedMultipleArgsMap. It stores a map of flag to vector of values.
Json can populate that map based on the values it reads. Otherwise the
command line parsing will populate this map.
When an argument using "multiple=true" is present in the JSON and in the
command line, simirarly than with other arguments, the values of the JSON are
ignored.

Testing for all the types that support the multiple argument is added.
The JSONModuleDescription did not escape the already escaped quote marks
correctly, causing build error:

error: expected ';' after top level declarator
"  \"Default\" : \"\\"1\\"\",\n"

Escaping the escape character fixes this. A parameter with a string
default with quotes is also added to testing to make sure that this works.

Reported-by: Andrey Fedorov <fedorov@bwh.harvard.edu>
Tested-by: Andrey Fedorov <fedorov@bwh.harvard.edu>
Thanks: Andrey Fedorov <fedorov@bwh.harvard.edu>
@johan-andruejol johan-andruejol force-pushed the FixDeserialazation-MultipleArgs branch from d607f3b to 768beb7 Compare September 2, 2016 18:13
@johan-andruejol
Copy link
Contributor Author

@jcfr: Thanks for all the comments ! I uploaded an updated version with all the fixes you suggested.

@jcfr jcfr merged commit 7f47109 into Slicer:master Sep 2, 2016
@jcfr
Copy link
Member

jcfr commented Sep 2, 2016

Thanks 👍

@fedorov
Copy link
Member

fedorov commented Sep 2, 2016

👍

@johan-andruejol johan-andruejol deleted the FixDeserialazation-MultipleArgs branch September 2, 2016 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants