tests/test-bugzilla.t
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sat, 21 May 2016 02:48:51 +0900
branchstable
changeset 29180 8c5e880c7e25
parent 28950 9e1c9f016b72
child 29102 22c53b3a390d
permissions -rw-r--r--
tests: escape bytes setting MSB in input of grep for portability GNU grep (2.21-2 or later) assumes that input is encoded in LC_CTYPE, and input is binary if it contains byte sequence not valid for that encoding. For example, if locale is configured as C, a byte setting most significant bit (MSB) makes such GNU grep show "Binary file <FILENAME> matches" message instead of matched lines unintentionally. This behavior is recognized as a bug, and fixed in GNU grep 2.25-1 or later. But some distributions are shipped with such buggy version (e.g. Ubuntu xenial, which is used by launchpad buildbot). http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19230 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800670 http://packages.ubuntu.com/xenial/grep This causes failure of test-commit-interactive.t, which applies grep on CP932 byte sequence since 1111e84de635. But, explicit setting LC_CTYPE for CP932 might cause another problem, because it can't be assumed that all environment running Mercurial tests allows arbitrary locale setting. To resolve this issue, this patch escapes bytes setting MSB in input of grep. For this purpose: - str.encode('string-escape') isn't useful, because it escapes also control code (less than 0x20), and makes EOL handling complicated - "f --hexdump" isn't useful, because it isn't line-oriented - "sed -n" seems reasonable, but "sed" itself sometimes causes portability issue, too (e.g. 900767dfa80d or afb86ee925bf) This patch is posted with "stable" flag, because 1111e84de635 is on stable branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28950
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     1
mock bugzilla driver for testing template output:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     2
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     3
  $ cat <<EOF > bzmock.py
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     4
  > from __future__ import absolute_import
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     5
  > from mercurial import extensions
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     6
  > 
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     7
  > def extsetup(ui):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     8
  >     bugzilla = extensions.find('bugzilla')
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     9
  >     class bzmock(bugzilla.bzaccess):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    10
  >         def __init__(self, ui):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    11
  >             super(bzmock, self).__init__(ui)
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    12
  >             self._logfile = ui.config('bugzilla', 'mocklog')
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    13
  >         def updatebug(self, bugid, newstate, text, committer):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    14
  >             with open(self._logfile, 'a') as f:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    15
  >                 f.write('update bugid=%r, newstate=%r, committer=%r\n'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    16
  >                         % (bugid, newstate, committer))
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    17
  >                 f.write('----\n' + text + '\n----\n')
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    18
  >         def notify(self, bugs, committer):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    19
  >             with open(self._logfile, 'a') as f:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    20
  >                 f.write('notify bugs=%r, committer=%r\n'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    21
  >                         % (bugs, committer))
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    22
  >     bugzilla.bugzilla._versions['mock'] = bzmock
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    23
  > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    24
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    25
set up mock repository:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    26
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    27
  $ hg init mockremote
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    28
  $ cat <<EOF > mockremote/.hg/hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    29
  > [extensions]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    30
  > bugzilla =
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    31
  > bzmock = $TESTTMP/bzmock.py
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    32
  > 
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    33
  > [bugzilla]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    34
  > version = mock
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    35
  > mocklog = $TESTTMP/bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    36
  > 
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    37
  > [hooks]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    38
  > incoming.bugzilla = python:hgext.bugzilla.hook
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    39
  > 
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    40
  > [web]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    41
  > baseurl=http://example.org/hg
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    42
  > 
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    43
  > %include $TESTTMP/bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    44
  > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    45
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    46
  $ hg clone -q mockremote mocklocal
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    47
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    48
push with default template:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    49
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    50
  $ echo '[bugzilla]' > bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    51
  $ echo foo > mocklocal/foo
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    52
  $ hg ci -R mocklocal -Aqm 'Fixes bug 123'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    53
  $ hg -R mocklocal push -q
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    54
  $ cat bzmock.log && rm bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    55
  update bugid=123, newstate={}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    56
  ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    57
  changeset 7875a8342c6f in repo $TESTTMP/mockremote refers to bug 123.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    58
  details:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    59
  	Fixes bug 123
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    60
  ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    61
  notify bugs={123: {}}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    62
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    63
push with style:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    64
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    65
  $ cat <<EOF > bzstyle.map
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    66
  > changeset = "{node|short} refers to bug {bug}."
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    67
  > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    68
  $ echo "style = $TESTTMP/bzstyle.map" >> bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    69
  $ echo foo >> mocklocal/foo
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    70
  $ hg ci -R mocklocal -qm 'Fixes bug 456'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    71
  $ hg -R mocklocal push -q
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    72
  $ cat bzmock.log && rm bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    73
  update bugid=456, newstate={}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    74
  ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    75
  2808b172464b refers to bug 456.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    76
  ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    77
  notify bugs={456: {}}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    78
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    79
push with template (overrides style):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    80
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    81
  $ cat <<EOF >> bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    82
  > template = Changeset {node|short} in {root|basename}.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    83
  >            {hgweb}/rev/{node|short}\n
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    84
  >            {desc}
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    85
  > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    86
  $ echo foo >> mocklocal/foo
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    87
  $ hg ci -R mocklocal -qm 'Fixes bug 789'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    88
  $ hg -R mocklocal push -q
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    89
  $ cat bzmock.log && rm bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    90
  update bugid=789, newstate={}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    91
  ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    92
  Changeset a770f3e409f2 in mockremote.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    93
  http://example.org/hg/rev/a770f3e409f2
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    94
  
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    95
  Fixes bug 789
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    96
  ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    97
  notify bugs={789: {}}, committer='test'