tests/test-hghave.t
author Matt Harbison <matt_harbison@yahoo.com>
Mon, 22 May 2017 21:45:02 -0400
changeset 32677 f840b2621cce
parent 26158 342ab95a1f4b
child 32942 5af78c524f34
permissions -rw-r--r--
killdaemons: close pid file before killing processes With #serve enabled on Windows, I was getting occasional stacktraces like this: Errored test-hgweb-json.t: Traceback (most recent call last): File "./run-tests.py", line 724, in run self.tearDown() File "./run-tests.py", line 805, in tearDown killdaemons(entry) File "./run-tests.py", line 540, in killdaemons logfn=vlog) File "...\tests\killdaemons.py", line 94, in killdaemons os.unlink(pidfile) WindowsError: [Error 32] The process cannot access the file because it is being used by another process: '...\\hgtests.zmpqj3\\child80\\daemon.pids' Adrian suggested using util.posixfile, which works. However, the 'mercurial' package isn't in sys.path when invoking run-tests.py, and it isn't clear that hacking[1] it in is a good thing (especially for test-run-tests.t, which uses an installation in a temp folder). I tried using ProcessMonitor to figure out what the other process is, but that monitoring slows things down to such a degree that the issue doesn't occur. I was ready to blame the virus scanner, but it happens without that too. Looking at the code, I don't see anything that would have the pid file open. But I was able to get through about 20 full test runs without an issue with this minor change, whereas before it was pretty certain to hit this at least once in two or three runs. [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097907.html
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12430
60738066e37a tests: unify test-hghave
Matt Mackall <mpm@selenic.com>
parents: 8059
diff changeset
     1
Testing that hghave does not crash when checking features
8059
41a2c5cbcb6a hghave: checking that all targets are Exception-free
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff changeset
     2
25472
4d2b9b304ad0 tests: drop explicit $TESTDIR from executables
Matt Mackall <mpm@selenic.com>
parents: 12430
diff changeset
     3
  $ hghave --test-features 2>/dev/null
25732
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
     4
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
     5
Testing hghave extensibility for third party tools
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
     6
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
     7
  $ cat > hghaveaddon.py <<EOF
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
     8
  > import hghave
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
     9
  > @hghave.check("custom", "custom hghave feature")
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    10
  > def has_custom():
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    11
  >     return True
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    12
  > EOF
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    13
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    14
(invocation via run-tests.py)
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    15
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    16
  $ cat > test-hghaveaddon.t <<EOF
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    17
  > #require custom
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    18
  >   $ echo foo
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    19
  >   foo
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    20
  > EOF
26158
342ab95a1f4b run-tests: use $HGTEST_RUN_TESTS_PURE
timeless@mozdev.org
parents: 25732
diff changeset
    21
  $ run-tests.py $HGTEST_RUN_TESTS_PURE test-hghaveaddon.t
25732
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    22
  .
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    23
  # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    24
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    25
(invocation via command line)
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    26
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    27
  $ unset TESTDIR
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    28
  $ hghave custom
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    29
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    30
(terminate with exit code 2 at failure of importing hghaveaddon.py)
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    31
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    32
  $ rm hghaveaddon.*
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    33
  $ cat > hghaveaddon.py <<EOF
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    34
  > importing this file should cause syntax error
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    35
  > EOF
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    36
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    37
  $ hghave custom
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    38
  failed to import hghaveaddon.py from '.': invalid syntax (hghaveaddon.py, line 1)
b94df10cc3b5 hghave: allow adding customized features at runtime
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 25472
diff changeset
    39
  [2]