[PATCH 2 of 2] tests: add a test case for loading an invalid file as python hook

Simon Heimberg simohe at besonet.ch
Wed Jul 4 02:03:35 CDT 2012


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1341384920 -7200
# Node ID b860401fecf31e7f07ce4ee98f41f2b6adb86fcc
# Parent  0dfaaae9a61922da1cd92d5963bacfd959c4f9a3
tests: add a test case for loading an invalid file as python hook

diff -r 0dfaaae9a619 -r b860401fecf3 tests/test-hook.t
--- a/tests/test-hook.t	Mit Jul 04 08:55:16 2012 +0200
+++ b/tests/test-hook.t	Mit Jul 04 08:55:20 2012 +0200
@@ -528,9 +528,12 @@
   nothing changed
   [1]
 
+  $ echo ? no python code > invalid
+
   $ echo '[hooks]' > .hg/hgrc
   $ echo "update.ne = python:`pwd`/nonexisting.py:testhook" >> .hg/hgrc
   $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
+  $ echo "commit.i = python:`pwd`/invalid:testhook" >> .hg/hgrc
 
   $ hg up null
   loading update.ne hook failed:
@@ -542,6 +545,19 @@
   abort: No module named repo!
   [255]
 
+  $ hg ci -A -m i 2>&1 | egrep -v '^( +File| {4}[a-zA-Z])'
+  adding invalid
+  loading commit.i hook failed:
+  ** unknown exception encountered, please report by visiting
+  ** http:* (glob)
+  ** Python * (glob)
+  ** Mercurial * (glob)
+  ** Extensions * (glob)
+  Traceback (most recent call last):
+      ? no python code
+      ^
+  SyntaxError: * (glob)
+
   $ cd ../../b
 
 make sure --traceback works on hook import failure


More information about the Mercurial-devel mailing list