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
1=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
2--- lib/lp/code/browser/sourcepackagerecipe.py 2010-11-24 08:05:42 +0000
3+++ lib/lp/code/browser/sourcepackagerecipe.py 2010-11-24 19:03:13 +0000
4@@ -305,10 +305,7 @@
5 parser = RecipeParser(data['recipe_text'])
6 parser.parse()
7 except RecipeParseError, error:
8- self.setFieldError(
9- 'recipe_text',
10- 'The recipe text is not a valid bzr-builder recipe. '
11- '%(error)s' % {'error': error.problem})
12+ self.setFieldError('recipe_text', str(error))
13
14
15 class SourcePackageRecipeAddView(RecipeTextValidatorMixin, LaunchpadFormView):
16
17=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
18--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-11-24 04:25:11 +0000
19+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-11-24 19:03:13 +0000
20@@ -301,8 +301,29 @@
21 branch=branch)
22 self.assertEqual(
23 get_message_text(browser, 2),
24- "The recipe text is not a valid bzr-builder recipe. "
25- "End of line while looking for '#'")
26+ "Error parsing recipe:1:1:"
27+ " End of line while looking for '#'.")
28+
29+ def test_create_recipe_usage(self):
30+ # The error for a recipe with invalid instruction parameters should
31+ # include instruction usage.
32+ branch = self.factory.makeBranch(name='veggies')
33+ package_branch = self.factory.makeBranch(name='packaging')
34+
35+ browser = self.createRecipe(
36+ dedent('''\
37+ # bzr-builder format 0.2 deb-version 0+{revno}
38+ %(branch)s
39+ merge
40+ ''' % {
41+ 'branch': branch.bzr_identity,
42+ }),
43+ branch=branch)
44+ self.assertEqual(
45+ 'Error parsing recipe:3:6: '
46+ 'End of line while looking for the branch id.\n'
47+ 'Usage: merge NAME BRANCH [REVISION]',
48+ get_message_text(browser, 2))
49
50 def test_create_recipe_no_distroseries(self):
51 browser = self.getViewBrowser(self.makeBranch(), '+new-recipe')
52
53=== modified file 'utilities/sourcedeps.conf'
54--- utilities/sourcedeps.conf 2010-11-12 23:30:57 +0000
55+++ utilities/sourcedeps.conf 2010-11-24 19:03:13 +0000
56@@ -1,4 +1,4 @@
57-bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=66
58+bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=68
59 bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=258
60 bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=283
61 bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=48