Aaron Bentley has proposed merging lp:~abentley/launchpad/better-recipe-errors into lp:launchpad/devel.
Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: #604718 Parse errors should give a "USAGE" for the line that they are parsing. https://bugs.launchpad.net/bugs/604718 = 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 -- https://code.launchpad.net/~abentley/launchpad/better-recipe-errors/+merge/41780 Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/better-recipe-errors into lp:launchpad/devel.
=== 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 @@ parser = RecipeParser(data['recipe_text']) parser.parse() except RecipeParseError, error: - self.setFieldError( - 'recipe_text', - 'The recipe text is not a valid bzr-builder recipe. ' - '%(error)s' % {'error': error.problem}) + self.setFieldError('recipe_text', str(error)) class SourcePackageRecipeAddView(RecipeTextValidatorMixin, LaunchpadFormView): === 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 @@ branch=branch) self.assertEqual( get_message_text(browser, 2), - "The recipe text is not a valid bzr-builder recipe. " - "End of line while looking for '#'") + "Error parsing recipe:1:1:" + " End of line while looking for '#'.") + + def test_create_recipe_usage(self): + # The error for a recipe with invalid instruction parameters should + # include instruction usage. + branch = self.factory.makeBranch(name='veggies') + package_branch = self.factory.makeBranch(name='packaging') + + browser = self.createRecipe( + dedent('''\ + # bzr-builder format 0.2 deb-version 0+{revno} + %(branch)s + merge + ''' % { + 'branch': branch.bzr_identity, + }), + branch=branch) + self.assertEqual( + 'Error parsing recipe:3:6: ' + 'End of line while looking for the branch id.\n' + 'Usage: merge NAME BRANCH [REVISION]', + get_message_text(browser, 2)) def test_create_recipe_no_distroseries(self): browser = self.getViewBrowser(self.makeBranch(), '+new-recipe') === 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 @@ -bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=66 +bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=68 bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=258 bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=283 bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=48
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp