From 2fe3015d986bc27bfd230d447ff9ba1c7cb946ce Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 28 Sep 2016 17:04:12 +0200 Subject: Options: Missing config file is not a fatal error If the config file is not available, it should not be a fatal error, but bcfg2 should just use the default config values. --- src/lib/Bcfg2/Options/Parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Bcfg2/Options/Parser.py b/src/lib/Bcfg2/Options/Parser.py index b72a495f1..dd5087f33 100644 --- a/src/lib/Bcfg2/Options/Parser.py +++ b/src/lib/Bcfg2/Options/Parser.py @@ -302,7 +302,7 @@ class Parser(argparse.ArgumentParser): # check whether the specified bcfg2.conf exists if not self.unit_test and not os.path.exists(bootstrap.config): - self.error("Could not read %s" % bootstrap.config) + sys.stderr.write("Could not read %s\n" % bootstrap.config) self.add_config_file(self.configfile.dest, bootstrap.config, reparse=False) -- cgit v1.2.3-1-g7c22 From 078a913ad179c12860aaafd5d8a75fa187ef0670 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 28 Sep 2016 21:10:31 +0200 Subject: testsuite: Missing config file should not raise SystemExit anymore --- testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py b/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py index 78acadf1f..6e2cda2c3 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py +++ b/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py @@ -47,4 +47,7 @@ class TestConfigFiles(OptionTestCase): @mock.patch("os.path.exists", mock.Mock(return_value=False)) def test_no_config_file(self): """fail to read config file.""" - self.assertRaises(SystemExit, self.parser.parse, []) + try: + self.parser.parse() + except SystemExit: + self.fail('Missing config file should not raise SystemExit') -- cgit v1.2.3-1-g7c22 From d5e3fe95e8565b2c9af730473e4b25aecf5395c5 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 4 Oct 2016 16:06:03 +0200 Subject: TestOptions: Do not try to parse the cmd args of the tests --- testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py b/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py index 6e2cda2c3..4277c8efe 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py +++ b/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py @@ -45,9 +45,10 @@ class TestConfigFiles(OptionTestCase): inner1() @mock.patch("os.path.exists", mock.Mock(return_value=False)) - def test_no_config_file(self): + @make_config() + def test_no_config_file(self, config): """fail to read config file.""" try: - self.parser.parse() + self.parser.parse(['-C', config]) except SystemExit: self.fail('Missing config file should not raise SystemExit') -- cgit v1.2.3-1-g7c22