commit bd6b96cecae94e224998379356e2ef1f82987a6e
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:04:59 2014 +0200
[pom_xpath_disable] fail when there's no match in any module
java-utils/pom_editor.py | 2 ++
test/pom_editor_modules_test.py | 8 +++++---
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py
index 95d6b96..76d6262 100644
--- a/java-utils/pom_editor.py
+++ b/java-utils/pom_editor.py
@@ -482,6 +482,8 @@ def pom_xpath_disable(when, pom=None):
if disable_recursive(pom):
raise PomException("Main POM satisfies the condition")
+ if not to_disable:
+ raise PomQueryNoMatch("Condition didn't match any module")
for pom, module in to_disable:
pom.patch(disable_module, {'pom': pom, 'module': module})
diff --git a/test/pom_editor_modules_test.py b/test/pom_editor_modules_test.py
index 30d2413..2c73dc2 100644
--- a/test/pom_editor_modules_test.py
+++ b/test/pom_editor_modules_test.py
@@ -4,10 +4,12 @@ import unittest
class TestPomXpathDisable(WorkdirTestCase):
def test_no_match(self):
- return_value, stderr, report = exec_pom_macro('%pom_xpath_disable nothing
submodule', {
+ return_value, stderr, _ = exec_pom_macro(
+ '''%pom_xpath_disable
"/pom:project/pom:groupId='not-there'" submodule''', {
'submodule': 'minimal_pom.xml'})
- self.assertEqual(0, return_value, stderr)
- self.assertEqual('', report, report)
+ assertIn(self, "Error", stderr)
+ assertIn(self, "didn't match", stderr)
+ self.assertNotEqual(0, return_value)
def test_nonexistent(self):
return_value, stderr, _ = exec_pom_macro('%pom_xpath_disable nothing',
{})