Skip to content

Commit 16cffec

Browse files
authored
Bring emcoverage tool back to life. NFC (emscripten-core#13598)
1 parent 5bc163a commit 16cffec

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

.coveragerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[run]
2+
source = .
3+
omit = ./tests/*
4+
./third_party/*
5+
./tools/emcoverage.py
6+
test.py
7+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
/node_modules/
1717

1818
# Python coverage tool output
19-
.coverage*
19+
.coverage
20+
.coverage.*
2021
tools/coverage/
2122
htmlcov/
2223
coverage.xml

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66

77
flake8==3.7.8
88
flake8-unused-arguments==0.0.6
9+
coverage==5.5

tools/emcoverage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
import coverage.cmdline
4040

41+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
42+
4143

4244
def main():
4345
# We hack sys.executable to point to this file, which is executable via #! line.
@@ -46,8 +48,9 @@ def main():
4648
# all of them will execute under the watchful eye of emcoverage.py, and resulting
4749
# in their code coverage being tracked.
4850
sys.executable = os.path.abspath(__file__)
51+
os.environ['EMSDK_PYTHON'] = sys.executable
4952

50-
store = os.path.join(os.path.dirname(sys.executable), 'coverage')
53+
store = os.path.join(SCRIPT_DIR, 'coverage')
5154

5255
if len(sys.argv) < 2 or sys.argv[1] == 'help':
5356
print(__doc__.replace('emcoverage.py', sys.argv[0]).strip())
@@ -64,7 +67,7 @@ def main():
6467
coverage.cmdline.main()
6568
except SystemExit:
6669
pass
67-
sys.argv = old_argv
70+
sys.argv = old_argv + ['-i']
6871
return coverage.cmdline.main()
6972

7073
if not os.path.exists(sys.argv[1]):
@@ -78,7 +81,7 @@ def main():
7881
if e.errno != errno.EEXIST:
7982
raise
8083
os.environ['COVERAGE_FILE'] = os.path.join(store, str(uuid.uuid4()))
81-
sys.argv[0:1] = ['coverage', 'run', '--parallel-mode', '--concurrency=multiprocessing', '--']
84+
sys.argv[0:1] = ['coverage', 'run', '--parallel-mode', '--']
8285

8386
return coverage.cmdline.main()
8487

0 commit comments

Comments
 (0)