Skip to content

Commit

Permalink
Adding test crumb finder to CI (#1582)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Jan 15, 2024
1 parent 2e7304b commit a9feedf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/find_test_crumbs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2024 TerraPower, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""This script exists so we can determine if new tests in CI are leaving crumbs."""

import subprocess

# A list of objects we expect during a run, and don't mind (like pycache dirs).
IGNORED_OBJECTS = [
".pytest_cache",
".tox",
"__pycache__",
"armi.egg-info",
"armi/logs/ARMI.armiRun.",
"armi/logs/armiRun.mpi.log",
"armi/tests/tutorials/case-suite/",
"armi/tests/tutorials/logs/",
]


def main():
# use "git clean" to find all non-tracked files
proc = subprocess.Popen(["git", "clean", "-xnd"], stdout=subprocess.PIPE)
lines = proc.communicate()[0].decode("utf-8").split("\n")

# clean up the whitespace
lines = [ln.strip() for ln in lines if len(ln.strip())]

# ignore certain untracked object, like __pycache__ dirs
for ignore in IGNORED_OBJECTS:
lines = [ln for ln in lines if ignore not in ln]

# fail hard if there are still untracked files
if len(lines):
for line in lines:
print(line)

raise ValueError("The workspace is dirty; the tests are leaving crumbs!")


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions .github/workflows/wintests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ jobs:
run: python -m pip install tox tox-gh-actions
- name: Run Tox
run: tox -e test
- name: Find Test Crumbs
run: python .github/workflows/find_test_crumbs.py

0 comments on commit a9feedf

Please sign in to comment.