diff --git a/.gitignore b/.gitignore index 1b96396a6..971e9b84a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ setuptools-*.egg .ruby-version # Stuff in the test directory. +covmain.zip zipmods.zip # Stuff in the doc directory. diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 9894c43bb..4cb09b6a3 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -58,6 +58,7 @@ Frazer McLean Geoff Bache George Paci George Song +George-Cristian Bîrzan Greg Rogers Guido van Rossum Guillaume Chazarain diff --git a/Makefile b/Makefile index 449271a9e..368a07ec8 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ clean: clean_platform ## Remove artifacts of test execution, i rm -f .coverage .coverage.* coverage.xml .metacov* rm -f .tox/*/lib/*/site-packages/zzz_metacov.pth rm -f */.coverage */*/.coverage */*/*/.coverage */*/*/*/.coverage */*/*/*/*/.coverage */*/*/*/*/*/.coverage - rm -f tests/zipmods.zip + rm -f tests/covmain.zip tests/zipmods.zip rm -rf tests/eggsrc/build tests/eggsrc/dist tests/eggsrc/*.egg-info rm -f setuptools-*.egg distribute-*.egg distribute-*.tar.gz rm -rf doc/_build doc/_spell doc/sample_html_beta diff --git a/igor.py b/igor.py index 56674c067..a742cb8e1 100644 --- a/igor.py +++ b/igor.py @@ -225,6 +225,10 @@ def do_zip_mods(): zf.close() + zf = zipfile.ZipFile("tests/covmain.zip", "w") + zf.write("coverage/__main__.py", "__main__.py") + zf.close() + def do_install_egg(): """Install the egg1 egg for tests.""" diff --git a/tests/test_process.py b/tests/test_process.py index ec6662c2e..6ca4571c6 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -23,7 +23,7 @@ from coverage.files import python_reported_file from coverage.misc import output_encoding -from tests.coveragetest import CoverageTest +from tests.coveragetest import CoverageTest, TESTS_DIR from tests.helpers import re_lines @@ -972,6 +972,17 @@ def test_coverage_run_dashm_is_like_python_dashm_with__main__207(self): actual = self.run_command("coverage run -m package") self.assertMultiLineEqual(expected, actual) + def test_coverage_zip_is_like_python(self): + # Test running coverage from a zip file itself. Some environments + # (windows?) zip up the coverage main to be used as the coverage + # command. + with open(TRY_EXECFILE) as f: + self.make_file("run_me.py", f.read()) + expected = self.run_command("python run_me.py") + cov_main = os.path.join(TESTS_DIR, "covmain.zip") + actual = self.run_command("python {} run run_me.py".format(cov_main)) + self.assert_tryexecfile_output(expected, actual) + def test_coverage_custom_script(self): # https://github.com/nedbat/coveragepy/issues/678 # If sys.path[0] isn't the Python default, then coverage.py won't