Patchwork tests: fix test-profile to not depend on HGPROF environment variable

login
register
mail settings
Submitter Durham Goode
Date March 12, 2013, 8:28 p.m.
Message ID <609c71ae10616f533840.1363120120@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1115/
State Accepted
Commit cd2c82510aa230585fa50736a9e05f169c812dad
Headers show

Comments

Durham Goode - March 12, 2013, 8:28 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1363109868 25200
#      Tue Mar 12 10:37:48 2013 -0700
# Node ID 609c71ae10616f533840db8accf6ee9b2e420b7f
# Parent  a039d7868d8546d0f83d46f28e720890a6e9594a
tests: fix test-profile to not depend on HGPROF environment variable

The test-profile test would fail if the user had HGPROF set to another
profiler in their environment.  This fix makes the test independent of
that environment variable.

Reverts the previous attempt to fix this, which was not cross platoform.
Bryan O'Sullivan - March 12, 2013, 8:46 p.m.
On Tue, Mar 12, 2013 at 1:28 PM, Durham Goode <durham@fb.com> wrote:

> tests: fix test-profile to not depend on HGPROF environment variable
>

Thanks for fixing this.


> +    if 'HGPROF' in os.environ:
> +        os.environ['HGPROF'] = ''
> +        del os.environ['HGPROF']
>

Why do you set this to the empty string, then delete it?
Durham Goode - March 12, 2013, 9:07 p.m.
On 3/12/13 1:46 PM, "Bryan O'Sullivan" <bos@serpentine.com> wrote:

>Why do you set this to the empty string, then delete it?
>

This is how the lines immediately prior do it.  The prior code has a
comment saying this is for solaris where they can't delete environment
variables.
Bryan O'Sullivan - March 12, 2013, 9:27 p.m.
On Tue, Mar 12, 2013 at 2:07 PM, Durham Goode <durham@fb.com> wrote:

> This is how the lines immediately prior do it.  The prior code has a
> comment saying this is for solaris where they can't delete environment
> variables.
>

OK, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1277,6 +1277,9 @@ 
         # can't remove on solaris
         os.environ['HG'] = ''
         del os.environ['HG']
+    if 'HGPROF' in os.environ:
+        os.environ['HGPROF'] = ''
+        del os.environ['HGPROF']
 
     global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE
     TESTDIR = os.environ["TESTDIR"] = os.getcwd()
diff --git a/tests/test-profile.t b/tests/test-profile.t
--- a/tests/test-profile.t
+++ b/tests/test-profile.t
@@ -8,8 +8,6 @@ 
 
 test --profile
 
-  $ export -n HGPROF
-
   $ hg --profile st 2>../out
   $ grep CallCount ../out > /dev/null || cat ../out