Skip to content

Commit

Permalink
Merge pull request #3655 from shubhambhar007/shubham/doctests
Browse files Browse the repository at this point in the history
Doctests do not remove built files if they fail #3389
  • Loading branch information
kratman committed Jan 3, 2024
2 parents 6d88e91 + 4fe3e00 commit 3bd05c4
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,36 +64,31 @@ def run_doc_tests():
used).
"""
print("Checking if docs can be built.")
p = subprocess.Popen(
[
"sphinx-build",
"-j",
"auto",
"-b",
"doctest",
"docs",
"docs/build/html",
"-W",
"--keep-going",
]
)
try:
ret = p.wait()
except KeyboardInterrupt:
subprocess.run(
[
"sphinx-build",
"-j",
"auto",
"-b",
"doctest",
"docs",
"docs/build/html",
"-W",
"--keep-going",
],
check=True,
)
except subprocess.CalledProcessError as e:
print(f"FAILED with exit code {e.returncode}")
sys.exit(e.returncode)
finally:
# Regardless of whether the doctests pass or fail, attempt to remove the built files.
print("Deleting built files.")
try:
p.terminate()
except OSError:
pass
p.wait()
print("")
sys.exit(1)
if ret != 0:
print("FAILED")
sys.exit(ret)
# delete the entire docs/source/build folder + files since it currently
# causes problems with nbsphinx in further docs or doctest builds
print("Deleting built files.")
shutil.rmtree("docs/build")
shutil.rmtree("docs/build/html/.doctrees/")
except Exception as e:
print(f"Error deleting built files: {e}")


def run_scripts(executable="python"):
Expand Down

0 comments on commit 3bd05c4

Please sign in to comment.