From c8bb7f2217fdc336cab6fc4b29d561ce17518c4d Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 29 Dec 2016 05:40:47 +0530 Subject: unit tests: Be more specific in checking for commands '-w' in c_command will check for it as a substring, which will also match '-wd', etc. So match it with quotes. This won't give us false positives, but might give us false negatives in case the argument is not quoted, but that's better behaviour for a test. The alternative is to split the string command, but the command does not necessarily obey shell quoting rules, so we cannot reliably use shlex.split(). --- run_unittests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/run_unittests.py b/run_unittests.py index 73268003e..3e8d32b01 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -221,15 +221,15 @@ class LinuxlikeTests(unittest.TestCase): self.assertIsNotNone(vala_command) self.assertIsNotNone(c_command) # -w suppresses all warnings, should be there in Vala but not in C - self.assertTrue('-w' in vala_command) - self.assertFalse('-w' in c_command) + self.assertTrue("'-w'" in vala_command) + self.assertFalse("'-w'" in c_command) # -Wall enables all warnings, should be there in C but not in Vala - self.assertFalse('-Wall' in vala_command) - self.assertTrue('-Wall' in c_command) + self.assertFalse("'-Wall'" in vala_command) + self.assertTrue("'-Wall'" in c_command) # -Werror converts warnings to errors, should always be there since it's # injected by an unrelated piece of code and the project has werror=true - self.assertTrue('-Werror' in vala_command) - self.assertTrue('-Werror' in c_command) + self.assertTrue("'-Werror'" in vala_command) + self.assertTrue("'-Werror'" in c_command) def test_static_compile_order(self): ''' -- cgit v1.2.3