ltl2tgba, randaut: better error reporting

* src/bin/ltl2tgba.cc, src/bin/randaut.cc: Catch exceptions
in main loop.
* src/tgbatest/ltl2tgba.test, src/tgbatest/randaut.test: Test
errors with unknown --dot argument.
This commit is contained in:
Alexandre Duret-Lutz 2015-01-04 11:24:31 +01:00
parent 5497bef3d0
commit 4d4c5d807b
4 changed files with 28 additions and 7 deletions

View file

@ -60,7 +60,7 @@ static const argp_option options[] =
/**************************************************/
{ "%f", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"the formula, in Spot's syntax", 4 },
/**************************************************/
/**************************************************/
{ 0, 0, 0, 0, "Miscellaneous options:", -1 },
{ "extra-options", 'x', "OPTS", 0,
"fine-tuning options (see spot-x (7))", 0 },
@ -182,7 +182,14 @@ main(int argc, char** argv)
trans.set_level(level);
trans_processor processor(trans);
if (processor.run())
return 2;
try
{
if (processor.run())
return 2;
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
return 0;
}

View file

@ -298,8 +298,15 @@ main(int argc, char** argv)
auto runtime = sw.stop();
printer.print(aut, nullptr,
opt_seed_str, automaton_num, runtime, nullptr);
try
{
printer.print(aut, nullptr,
opt_seed_str, automaton_num, runtime, nullptr);
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
++automaton_num;
if (opt_automata > 0 && automaton_num >= opt_automata)

View file

@ -1,7 +1,7 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Laboratoire
# de Recherche et Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie.
@ -201,3 +201,7 @@ grep 'states: 4$' stdout
../../bin/ltlfilt -r -f '!{{a;b}[*]}' --equivalent-to '!a | X!b'
../../bin/ltlfilt -f '{a[*];b[*]}' --equivalent-to 'a | b'
../../bin/ltlfilt -r -f '{a[*];b[*]}' --equivalent-to 'a | b'
# test unknown dot options
../../bin/ltl2tgba --dot=@ a 2>stderr && exit 1
grep 'ltl2tgba: unknown option.*@' stderr

View file

@ -68,3 +68,6 @@ diff out expected
$randaut -n 5 --stats='name: "%F-%L-%s-%c-%e"' a >out2
diff out2 expected
$randaut -n 5 --dot=@ a 2>stderr && exit 1
grep 'randaut: unknown option.*@' stderr