Patchwork [V3] tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it

login
register
mail settings
Submitter Pulkit Goyal
Date June 20, 2020, 9:20 a.m.
Message ID <a2373d25ab8eff980b9c.1592644823@workspace>
Download mbox | patch
Permalink /patch/46538/
State Accepted
Headers show

Comments

Pulkit Goyal - June 20, 2020, 9:20 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1592396190 -19800
#      Wed Jun 17 17:46:30 2020 +0530
# Node ID a2373d25ab8eff980b9c2e70752e293cdf6c822e
# Parent  c4ad2502afcfe840f15e10cdaf321b84c96ae185
# EXP-Topic chg-test
tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it

setprocname is not present when we build a pure version. This leads to output
changes in test-chg.t

This should make test suite green on Python 2 pure build with chg.

Differential Revision: https://phab.mercurial-scm.org/D8638
Yuya Nishihara - June 20, 2020, 10:52 a.m.
On Sat, 20 Jun 2020 14:50:23 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1592396190 -19800
> #      Wed Jun 17 17:46:30 2020 +0530
> # Node ID a2373d25ab8eff980b9c2e70752e293cdf6c822e
> # Parent  c4ad2502afcfe840f15e10cdaf321b84c96ae185
> # EXP-Topic chg-test
> tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it

Queued, thanks.

> +@check("setprocname", "whether osutil.procname is available or not")

s/\.procname/setprocname/ in flight.
Pulkit Goyal - June 20, 2020, 11:03 a.m.
On Sat, 20 Jun, 2020, 16:23 Yuya Nishihara, <yuya@tcha.org> wrote:

> On Sat, 20 Jun 2020 14:50:23 +0530, Pulkit Goyal wrote:
> > # HG changeset patch
> > # User Pulkit Goyal <7895pulkit@gmail.com>
> > # Date 1592396190 -19800
> > #      Wed Jun 17 17:46:30 2020 +0530
> > # Node ID a2373d25ab8eff980b9c2e70752e293cdf6c822e
> > # Parent  c4ad2502afcfe840f15e10cdaf321b84c96ae185
> > # EXP-Topic chg-test
> > tests: add hghave rule 'setprocname' to check if osutil.setprocname and
> use it
>
> Queued, thanks.
>
> > +@check("setprocname", "whether osutil.procname is available or not")
>
> s/\.procname/setprocname/ in flight.
>

Oops. Thank you for fixing in flight.

>

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -683,6 +683,17 @@  def has_serve():
     return True
 
 
+@check("setprocname", "whether osutil.procname is available or not")
+def has_setprocname():
+    try:
+        from mercurial.utils import procutil
+
+        procutil.setprocname
+        return True
+    except AttributeError:
+        return False
+
+
 @check("test-repo", "running tests from repository")
 def has_test_repo():
     t = os.environ["TESTDIR"]
diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -229,13 +229,13 @@  check that server events are recorded:
   server.log.1
 
 print only the last 10 lines, since we aren't sure how many records are
-preserved (since setprocname isn't available on py3, the 10th-most-recent line
-is different when using py3):
+preserved (since setprocname isn't available on py3 and pure version,
+the 10th-most-recent line is different when using py3):
 
   $ cat log/server.log.1 log/server.log | tail -10 | filterlog
-  YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (py3 !)
+  YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (no-setprocname !)
   YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
-  YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (no-py3 !)
+  YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (setprocname !)
   YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
   YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
   YYYY/MM/DD HH:MM:SS (PID)> setumask 18