Merge lp:~abentley/launchpad/better-recipe-errors into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 11992
Proposed branch: lp:~abentley/launchpad/better-recipe-errors
Merge into: lp:launchpad
Diff against target: 61 lines (+25/-7)
3 files modified
lib/lp/code/browser/sourcepackagerecipe.py (+1/-4)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+23/-2)
utilities/sourcedeps.conf (+1/-1)
To merge this branch: bzr merge lp:~abentley/launchpad/better-recipe-errors
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+41780@code.launchpad.net

Commit message

Show useage for recipe instruction parse errors.

Description of the change

= Summary =
Fix bug #604718: Parse errors should give a "USAGE" for the line that they are parsing.
Fix bug #677672: Doesn't give information about where parse errors occur

== Proposed fix ==
Update to the latest version of bzr-builder, which incorporates usage messages.
Use the exception message verbatim, so that both usage and line/column
information is provided.

== Pre-implementation notes ==
None

== Implementation details ==
None

== Tests ==

== Demo and Q/A ==
bin/test -t test_create_recipe_usage -t test_create_recipe_bad_text

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/code/browser/sourcepackagerecipe.py
  utilities/sourcedeps.conf
  lib/lp/code/browser/tests/test_sourcepackagerecipe.py

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
--- lib/lp/code/browser/sourcepackagerecipe.py 2010-11-24 08:05:42 +0000
+++ lib/lp/code/browser/sourcepackagerecipe.py 2010-11-24 19:03:13 +0000
@@ -305,10 +305,7 @@
305 parser = RecipeParser(data['recipe_text'])305 parser = RecipeParser(data['recipe_text'])
306 parser.parse()306 parser.parse()
307 except RecipeParseError, error:307 except RecipeParseError, error:
308 self.setFieldError(308 self.setFieldError('recipe_text', str(error))
309 'recipe_text',
310 'The recipe text is not a valid bzr-builder recipe. '
311 '%(error)s' % {'error': error.problem})
312309
313310
314class SourcePackageRecipeAddView(RecipeTextValidatorMixin, LaunchpadFormView):311class SourcePackageRecipeAddView(RecipeTextValidatorMixin, LaunchpadFormView):
315312
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-11-24 04:25:11 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-11-24 19:03:13 +0000
@@ -301,8 +301,29 @@
301 branch=branch)301 branch=branch)
302 self.assertEqual(302 self.assertEqual(
303 get_message_text(browser, 2),303 get_message_text(browser, 2),
304 "The recipe text is not a valid bzr-builder recipe. "304 "Error parsing recipe:1:1:"
305 "End of line while looking for '#'")305 " End of line while looking for '#'.")
306
307 def test_create_recipe_usage(self):
308 # The error for a recipe with invalid instruction parameters should
309 # include instruction usage.
310 branch = self.factory.makeBranch(name='veggies')
311 package_branch = self.factory.makeBranch(name='packaging')
312
313 browser = self.createRecipe(
314 dedent('''\
315 # bzr-builder format 0.2 deb-version 0+{revno}
316 %(branch)s
317 merge
318 ''' % {
319 'branch': branch.bzr_identity,
320 }),
321 branch=branch)
322 self.assertEqual(
323 'Error parsing recipe:3:6: '
324 'End of line while looking for the branch id.\n'
325 'Usage: merge NAME BRANCH [REVISION]',
326 get_message_text(browser, 2))
306327
307 def test_create_recipe_no_distroseries(self):328 def test_create_recipe_no_distroseries(self):
308 browser = self.getViewBrowser(self.makeBranch(), '+new-recipe')329 browser = self.getViewBrowser(self.makeBranch(), '+new-recipe')
309330
=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf 2010-11-12 23:30:57 +0000
+++ utilities/sourcedeps.conf 2010-11-24 19:03:13 +0000
@@ -1,4 +1,4 @@
1bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=661bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=68
2bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=2582bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=258
3bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=2833bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=283
4bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=484bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=48