Patchwork D1433: run-tests: fix TESTDIR if testdescs are absolute paths

login
register
mail settings
Submitter phabricator
Date Nov. 16, 2017, 4:41 a.m.
Message ID <differential-rev-PHID-DREV-qdjf43mkfi4ytkeyd4js-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25593/
State Superseded
Headers show

Comments

phabricator - Nov. 16, 2017, 4:41 a.m.
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Commit https://phab.mercurial-scm.org/rHGa18eef03d879b179c69744ff3568615402542938 made TESTDIR be the location of the arguments that were
  passed to run-tests.py instead of just PWD.  It assumed that these tests were
  specified using relative paths, so if pwd was /tmp/foo, and the first argument
  was /tmp/baz, it would set TESTDIR to /tmp/foo//tmp/baz.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1433

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: spectral, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 16, 2017, 2:38 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Looks good, but perhaps we can simply do `os.path.join(TESTDIR, pathname)`
  for any pathname.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1433

To: spectral, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Nov. 16, 2017, 8:42 p.m.
spectral added a comment.


  In https://phab.mercurial-scm.org/D1433#23806, @yuja wrote:
  
  > Looks good, but perhaps we can simply do `os.path.join(TESTDIR, pathname)`
  >  for any pathname.
  
  
  I didn't think that would work because of bytes, but apparently it does, at least on 2.7.13 and 3.5.3 on my linux machine.  Done.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1433

To: spectral, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Nov. 17, 2017, 1:33 p.m.
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Queued, thanks. FIle APIs still accept bytes/unicode on Py3.

INLINE COMMENTS

> run-tests.py:2359
>              pathname = os.path.dirname(testdescs[0]['path'])
> -            if pathname and not osenvironb[b'TESTDIR'].endswith(b'/'):
> -                osenvironb[b'TESTDIR'] += b'/'
> -            osenvironb[b'TESTDIR'] += pathname
> +            osenvironb[b'TESTDIR'] = os.path.join(osenvironb[b'TESTDIR'],
> +                                                  pathname)

Restored `if pathname:` part, caught by test-run-tests.t

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1433

To: spectral, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2356,9 +2356,12 @@ 
         # assume all tests in same folder for now
         if testdescs:
             pathname = os.path.dirname(testdescs[0]['path'])
-            if pathname and not osenvironb[b'TESTDIR'].endswith(b'/'):
-                osenvironb[b'TESTDIR'] += b'/'
-            osenvironb[b'TESTDIR'] += pathname
+            if pathname and pathname[0].startswith(b'/'):
+                osenvironb[b'TESTDIR'] = pathname
+            else:
+                if pathname and not osenvironb[b'TESTDIR'].endswith(b'/'):
+                    osenvironb[b'TESTDIR'] += b'/'
+                osenvironb[b'TESTDIR'] += pathname
         if self.options.outputdir:
             self._outputdir = canonpath(_bytespath(self.options.outputdir))
         else: