This repository was archived by the owner on Aug 5, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change 5858 tofile = "-" ,
5959 lineterm = "" )
6060diffs = list (unified )
61- if not diffs :
62- sys .exit (0 )
63- else :
61+ if diffs :
6462 for d in diffs :
6563 print (d )
6664 sys .exit (1 )
65+ if process .wait () != 1 :
66+ print ("Error: Expected 1 error, found {}" .format (process .returncode ))
67+ sys .exit (1 )
Original file line number Diff line number Diff line change @@ -31,3 +31,5 @@ domainGroup: EddGroup
3131 component: /Test/test/block/1
3232 q2.5 = 0
3333 string = some other string
34+ # Should trigger a non fatal error
35+ domain: First
Original file line number Diff line number Diff line change 4242
4343def parseArgs ():
4444 argparser = argparse .ArgumentParser (description = "Parameter-Framework XML \
45- Settings file generator" )
45+ Settings file generator.\n \
46+ Exit with the number of (recoverable or not) error that occured." )
4647 argparser .add_argument ('--toplevel-config' ,
4748 help = "Top-level parameter-framework configuration file. Mandatory." ,
4849 metavar = "TOPLEVEL_CONFIG_FILE" ,
@@ -183,6 +184,7 @@ def main():
183184 # EDD files (aka ".pfw" files)
184185 #
185186 parsed_edds = parseEdd (args .edd_files , args .verbose )
187+ error_nb = 0
186188
187189 # We need to modify the toplevel configuration file to account for differences
188190 # between development setup and target (installation) setup, in particular, the
@@ -218,7 +220,8 @@ def main():
218220 connector .stdin .close ()
219221 connector .wait ()
220222 fake_toplevel_config .delete ()
223+ return connector .return_code
221224
222225# If this file is directly executed
223226if __name__ == "__main__" :
224- main ()
227+ exit ( main () )
Original file line number Diff line number Diff line change @@ -215,9 +215,21 @@ static const char *usage =
215215
216216All arguments are mandatory. If no validation is required,
217217the path to the schemas can be an empty string.
218+
219+ Exit with the number of (recoverable or not error) that occured.
220+
218221This program is not intended to be used standalone but rather called through
219222domainGenerator.py)" ;
220223
224+ /* * On linux at least, a program can not exit with a value greater than 255.
225+ * @return min(code, 255);
226+ */
227+ template <class T >
228+ static inline int normalizeExitCode (T code)
229+ {
230+ return int (std::min<T>(code, std::numeric_limits<uint8_t >::max ()));
231+ }
232+
221233int main (int argc, char *argv[])
222234{
223235 using std::endl;
@@ -246,8 +258,8 @@ int main(int argc, char *argv[])
246258 // TODO: add a check for conflicting elements
247259 xmlGenerator.exportDomains (std::cout);
248260
249- return int (std::min< decltype ( errorNb)>(errorNb, std::numeric_limits< uint8_t >:: max ()) );
250- } catch (runtime_error e) {
261+ return normalizeExitCode ( errorNb);
262+ } catch (std::exception & e) {
251263 std::cerr << e.what () << std::endl;
252264 return 1 ;
253265 }
You can’t perform that action at this time.
0 commit comments