Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated coveragerc file #923

Merged
merged 8 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ omit =
armi/utils/tests/test_gridGui.py
venv/
source = armi
# change default .coverage file to something that doesn't have a dot
# because our Windows file server can't handle dots. :s
data_file = coverage_results.cov

[coverage:run]
parallel = true
Expand Down
31 changes: 28 additions & 3 deletions armi/cases/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import glob
import os
import pathlib
import platform
import pstats
import re
import shutil
import sys
import textwrap
import time
Expand Down Expand Up @@ -380,7 +382,7 @@ def _startCoverage(self):
cov = None
if self.cs["coverage"]:
cov = coverage.Coverage(
config_file=os.path.join(context.RES, "coveragerc"), debug=["dataio"]
config_file=Case._getCoverageRcFile(makeCopy=True), debug=["dataio"]
)
if context.MPI_SIZE > 1:
# interestingly, you cannot set the parallel flag in the constructor
Expand Down Expand Up @@ -415,8 +417,7 @@ def _endCoverage(cov=None):
# combine all the parallel coverage data files into one and make
# the XML and HTML reports for the whole run.
combinedCoverage = coverage.Coverage(
config_file=os.path.join(context.RES, "coveragerc"),
debug=["dataio"],
config_file=Case._getCoverageRcFile(), debug=["dataio"]
)
combinedCoverage.config.parallel = True
# combine does delete the files it merges
Expand All @@ -425,6 +426,30 @@ def _endCoverage(cov=None):
combinedCoverage.html_report()
combinedCoverage.xml_report()

@staticmethod
def _getCoverageRcFile(makeCopy=False):
"""Helper to provide the coverage configuration file according to the OS.

Parameters
----------
makeCopy : bool (optional)
Whether or not to copy the coverage config file to an alternate file path

Returns
-------
covFile : str
path of coveragerc file
"""
covRcDir = os.path.abspath(context.PROJECT_ROOT)
covFile = os.path.join(covRcDir, ".coveragerc")
if platform.system() == "Windows":
covFileWin = os.path.join(covRcDir, "coveragerc")
if makeCopy == True:
# Make a copy of the file without the dot in the name
shutil.copy(covFile, covFileWin)
return covFileWin
return covFile
john-science marked this conversation as resolved.
Show resolved Hide resolved

def _startProfiling(self):
"""Helper to the Case.run(): start the Python profiling,
if the CaseSettings file says to.
Expand Down
13 changes: 10 additions & 3 deletions armi/cases/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
import logging
import os
import platform
import sys
import unittest

import coverage

from armi import cases
from armi import context
from armi import getApp
Expand Down Expand Up @@ -124,6 +121,16 @@ def test_independentVariables(self):
for name, val in vals.items():
self.assertEqual(newCase.independentVariables[name], val)

def test_getCoverageRcFile(self):
case = cases.Case(settings.Settings())
covRcDir = os.path.abspath(context.PROJECT_ROOT)
# Don't actually copy the file, just check the file paths match
covRcFile = case._getCoverageRcFile(makeCopy=False)
if platform.system() == "Windows":
self.assertEqual(covRcFile, os.path.join(covRcDir, "coveragerc"))
else:
self.assertEqual(covRcFile, os.path.join(covRcDir, ".coveragerc"))

def test_startCoverage(self):
with directoryChangers.TemporaryDirectoryChanger():
cs = settings.Settings(ARMI_RUN_PATH)
Expand Down
3 changes: 2 additions & 1 deletion armi/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def setMode(cls, mode):


ROOT = os.path.abspath(os.path.dirname(__file__))
PROJECT_ROOT = os.path.join(ROOT, "..")
RES = os.path.join(ROOT, "resources")
DOC = os.path.abspath(os.path.join(ROOT, "..", "doc"))
DOC = os.path.abspath(os.path.join(PROJECT_ROOT, "doc"))
USER = getpass.getuser()
START_TIME = time.ctime()

Expand Down
16 changes: 0 additions & 16 deletions armi/resources/coveragerc

This file was deleted.

1 change: 1 addition & 0 deletions doc/release/0.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ What's new in ARMI
------------------

#. TBD
#. Cleanup of stale ``coveragerc`` file (`PR#923 <https://github.com/terrapower/armi/pull/923>`_)
#. Added writer style option to ``SettingsWriter`` and added it as arg to modify CLI (`PR#924 <https://github.com/terrapower/armi/pull/924>`_)

Bug fixes
Expand Down