Added PetscOptionsInsertStringYAML and -options_string_yaml
I'm going to teach a class on iterative methods and I'd like to be able to use PETSc's command line options to demonstrate the convergence behavior of different methods. As nice as the colors are that Matt and Patrick have used to highlight portions of compound prefixes in the past, the verbosity is distracting when PETSc isn't the subject of the lesson.
Parsing YAML from files already formed a string from the file contents, so I just refactored the code to let the user insert YAML-formatted string, and a matching -options_string_yaml
command line option.
In order to test this new feature, I had to add the ability to parse strings
with newlines in the 'args:' of tests. sys/tests/ex23.c
now has a test that looks like
/*TEST
test:
suffix: string
requires: yaml
args: -options_string_yaml "
foo: &foo
view: true
max: &foomax
steps: 3
time: 1.4
bar: &bar
max_it: 5
ts:
<<: *foo
max:
<<: *foomax
steps: 10
snes: *bar"
TEST*/
[EDIT: If you give a mouse a YAML input option, he's going to want anchors, aliases, and the merge key, so I added support for those that you can see in the example above.]
I use a shell parser that ships with python2 and python3 (shlex) to avoid stripping newlines inside of quotation marks.
After cleaning up one other example (-d" "
may be a valid shell token, but the parser likes it better as -d " "
) and the test harness (using "$@"
instead of $*
), it worked on my laptop.