summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--igor.py18
-rw-r--r--setup.py2
-rw-r--r--tests/coveragetest.py7
-rw-r--r--tests/test_parser.py3
-rw-r--r--tests/test_venv.py7
5 files changed, 28 insertions, 9 deletions
diff --git a/igor.py b/igor.py
index e2f063fd..657cb2bc 100644
--- a/igor.py
+++ b/igor.py
@@ -56,7 +56,7 @@ def do_show_env():
print(f" {env} = {os.environ[env]!r}")
-def do_remove_extension():
+def do_remove_extension(*args):
"""Remove the compiled C extension, no matter what its name."""
so_patterns = """
@@ -66,8 +66,22 @@ def do_remove_extension():
tracer.*.pyd
""".split()
+ if "--from-install" in args:
+ # Get the install location using a subprocess to avoid
+ # locking the file we are about to delete
+ root = os.path.dirname(subprocess.check_output([
+ sys.executable,
+ "-Xutf8",
+ "-c",
+ "import coverage; print(coverage.__file__)"
+ ], encoding="utf-8").strip())
+ else:
+ root = "coverage"
+
for pattern in so_patterns:
- pattern = os.path.join("coverage", pattern)
+ pattern = os.path.join(root, pattern.strip())
+ if VERBOSITY:
+ print(f"Searching for {pattern}")
for filename in glob.glob(pattern):
if os.path.exists(filename):
if VERBOSITY:
diff --git a/setup.py b/setup.py
index 00f6086d..46f764da 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ import sys
# Setuptools has to be imported before distutils, or things break.
from setuptools import setup
from distutils.core import Extension # pylint: disable=wrong-import-order
-from distutils.command.build_ext import build_ext # pylint: disable=wrong-import-order
+from setuptools.command.build_ext import build_ext # pylint: disable=wrong-import-order
from distutils import errors # pylint: disable=wrong-import-order
import distutils.log # pylint: disable=wrong-import-order
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 80bcdfc0..78254156 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -33,6 +33,11 @@ OK, ERR = 0, 1
# The coverage/tests directory, for all sorts of finding test helping things.
TESTS_DIR = os.path.dirname(__file__)
+# Install arguments to pass to pip when reinstalling ourselves.
+# Defaults to the top of the source tree, but can be overridden if we need
+# some help on certain platforms.
+COVERAGE_INSTALL_ARGS = os.getenv("COVERAGE_INSTALL_ARGS", nice_file(TESTS_DIR, ".."))
+
class CoverageTest(
StdStreamCapturingMixin,
@@ -415,7 +420,7 @@ class CoverageTest(
def working_root(self):
"""Where is the root of the coverage.py working tree?"""
- return os.path.dirname(nice_file(coverage.__file__, ".."))
+ return os.path.dirname(nice_file(__file__, ".."))
def report_from_command(self, cmd):
"""Return the report from the `cmd`, with some convenience added."""
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 2393ccd1..29c93035 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -510,8 +510,9 @@ def test_ast_dump():
# Run the AST_DUMP code to make sure it doesn't fail, with some light
# assertions. Use parser.py as the test code since it is the longest file,
# and fitting, since it's the AST_DUMP code.
+ import coverage.parser
files = [
- os.path.join(TESTS_DIR, "../coverage/parser.py"),
+ coverage.parser.__file__,
os.path.join(TESTS_DIR, "stress_phystoken.tok"),
]
for fname in files:
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 6e997be2..0fe30a49 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -12,8 +12,8 @@ import pytest
from coverage import env
-from tests.coveragetest import CoverageTest, TESTS_DIR
-from tests.helpers import change_dir, make_file, nice_file
+from tests.coveragetest import CoverageTest, COVERAGE_INSTALL_ARGS
+from tests.helpers import change_dir, make_file
from tests.helpers import re_lines, run_command
@@ -138,13 +138,12 @@ def venv_world_fixture(tmp_path_factory):
""")
# Install everything.
- coverage_src = nice_file(TESTS_DIR, "..")
run_in_venv(
"python -m pip install --no-index " +
"./third_pkg " +
"-e ./another_pkg " +
"-e ./bug888/app -e ./bug888/plugin " +
- coverage_src
+ COVERAGE_INSTALL_ARGS
)
shutil.rmtree("third_pkg")