-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test crumb finder to CI (#1582)
- Loading branch information
1 parent
2e7304b
commit a9feedf
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters