tests/test-cat.t
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 10 Apr 2017 16:53:37 +0200
changeset 31969 face2b5493fb
parent 30833 bd5e9647f646
child 32584 746e12a767b3
permissions -rw-r--r--
obsolescence: add test case D-1 for obsolescence markers exchange About 3 years ago, in August 2014, the logic to select what markers to select on push was ported from the evolve extension to Mercurial core. However, for some unclear reasons, the tests for that logic were not ported alongside. I realised it a couple of weeks ago while working on another push related issue. I've made a clean up pass on the tests and they are now ready to integrate the core test suite. This series of changesets do not change any logic. I just adds test for logic that has been around for about 10 versions of Mercurial. They are a patch for each test case. It makes it easier to review and postpone one with documentation issues without rejecting the wholes series. This patch introduce case D-1: Pruned changeset based on missing precursor of something not present Each test case comes it in own test file. It help parallelism and does not introduce a significant overhead from having a single unified giant test file. Here are timing to support this claim. # Multiple test files version: # run-tests.py --local -j 1 test-exchange-*.t 53.40s user 6.82s system 85% cpu 1:10.76 total 52.79s user 6.97s system 85% cpu 1:09.97 total 52.94s user 6.82s system 85% cpu 1:09.69 total # Single test file version: # run-tests.py --local -j 1 test-exchange-obsmarkers.t 52.97s user 6.85s system 85% cpu 1:10.10 total 52.64s user 6.79s system 85% cpu 1:09.63 total 53.70s user 7.00s system 85% cpu 1:11.17 total
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     1
  $ hg init
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     2
  $ echo 0 > a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     3
  $ echo 0 > b
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12070
diff changeset
     4
  $ hg ci -A -m m
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     5
  adding a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     6
  adding b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     7
  $ hg rm a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     8
  $ hg cat a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
     9
  0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    10
  $ hg cat --decode a # more tests in test-encode
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    11
  0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    12
  $ echo 1 > b
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12070
diff changeset
    13
  $ hg ci -m m
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    14
  $ echo 2 > b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    15
  $ hg cat -r 0 a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    16
  0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    17
  $ hg cat -r 0 b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    18
  0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    19
  $ hg cat -r 1 a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12070
diff changeset
    20
  a: no such file in rev 7040230c159c
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
    21
  [1]
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    22
  $ hg cat -r 1 b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
    23
  1
17371
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    24
24381
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    25
Test multiple files
17371
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    26
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    27
  $ echo 3 > c
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    28
  $ hg ci -Am addmore c
24381
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    29
  $ hg cat b c
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    30
  1
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    31
  3
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    32
  $ hg cat .
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    33
  1
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    34
  3
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    35
  $ hg cat . c
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    36
  1
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    37
  3
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    38
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    39
Test fileset
82b82168d045 context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents: 21078
diff changeset
    40
17371
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    41
  $ hg cat 'set:not(b) or a'
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    42
  3
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    43
  $ hg cat 'set:c or b'
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    44
  1
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    45
  3
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
    46
21078
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    47
  $ mkdir tmp
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    48
  $ hg cat --output tmp/HH_%H c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    49
  $ hg cat --output tmp/RR_%R c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    50
  $ hg cat --output tmp/h_%h c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    51
  $ hg cat --output tmp/r_%r c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    52
  $ hg cat --output tmp/%s_s c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    53
  $ hg cat --output tmp/%d%%_d c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    54
  $ hg cat --output tmp/%p_p c
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    55
  $ hg log -r . --template "{rev}: {node|short}\n"
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    56
  2: 45116003780e
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    57
  $ find tmp -type f | sort
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    58
  tmp/.%_d
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    59
  tmp/HH_45116003780e3678b333fb2c99fa7d559c8457e9
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    60
  tmp/RR_2
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    61
  tmp/c_p
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    62
  tmp/c_s
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    63
  tmp/h_45116003780e
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    64
  tmp/r_2
50107a4b32e7 cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents: 17371
diff changeset
    65
24720
c560d8c68791 cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents: 24381
diff changeset
    66
Test working directory
c560d8c68791 cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents: 24381
diff changeset
    67
c560d8c68791 cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents: 24381
diff changeset
    68
  $ echo b-wdir > b
c560d8c68791 cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents: 24381
diff changeset
    69
  $ hg cat -r 'wdir()' b
c560d8c68791 cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents: 24381
diff changeset
    70
  b-wdir
30833
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    71
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    72
Environment variables are not visible by default
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    73
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    74
  $ PATTERN='t4' hg log -r '.' -T "{ifcontains('PATTERN', envvars, 'yes', 'no')}\n"
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    75
  no
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    76
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    77
Environment variable visibility can be explicit
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    78
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    79
  $ PATTERN='t4' hg log -r '.' -T "{envvars % '{key} -> {value}\n'}" \
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    80
  >                 --config "experimental.exportableenviron=PATTERN"
bd5e9647f646 templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents: 24720
diff changeset
    81
  PATTERN -> t4