Skip to content

Remove engine binary after tests#1058

Merged
sroet merged 2 commits into
openpathsampling:masterfrom
sroet:fix_external_engine_teardown
Aug 29, 2021
Merged

Remove engine binary after tests#1058
sroet merged 2 commits into
openpathsampling:masterfrom
sroet:fix_external_engine_teardown

Conversation

@sroet

@sroet sroet commented Aug 27, 2021

Copy link
Copy Markdown
Member

@bdice identified an issue with our tests leaving files around after running the test. This is bad test design and should be avoided.

This PR fixes the offending test

@codecov

codecov Bot commented Aug 27, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1058 (0655578) into master (5035ba5) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1058   +/-   ##
=======================================
  Coverage   81.57%   81.57%           
=======================================
  Files         140      140           
  Lines       15413    15413           
=======================================
  Hits        12573    12573           
  Misses       2840     2840           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5035ba5...0655578. Read the comment docs.

@bdice bdice mentioned this pull request Aug 27, 2021
for testfile in glob.glob("test*out") + glob.glob("test*inp"):
os.remove(testfile)
engine_binary = os.path.join(engine_dir, "engine")
os.remove(engine_binary)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the commented code calling make clean was intended to do this same thing. Perhaps that comment can be deleted, or uncommented instead of adding this fix? It looks like it was introduced in this commit and never enabled.

@sroet sroet Aug 27, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my vote is to keep as much of our tests inside the same python process (so keeping this code but removing the comments) but I will default to whatever @dwhswenson thinks is best (as the original author of that commit)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with the make clean (assuming it works!) My guess is that when I was first iterating on external engines, I felt like compilation was slowing down the tests. So I probably disabled the make clean, since the source files weren't changing at that point.

The advantages of using make clean are:

  1. Keeps abstraction of the C code compilation separate from the Python.
  2. Gives a better template/example for more complex use cases (if you were testing against a more complicated compilation that generated a bunch of object files, you'd want your make clean to remove all those .o files -- that would make more sense than doing that in Python).

@dwhswenson dwhswenson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the make clean approach makes more sense. See line comment.

for testfile in glob.glob("test*out") + glob.glob("test*inp"):
os.remove(testfile)
engine_binary = os.path.join(engine_dir, "engine")
os.remove(engine_binary)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with the make clean (assuming it works!) My guess is that when I was first iterating on external engines, I felt like compilation was slowing down the tests. So I probably disabled the make clean, since the source files weren't changing at that point.

The advantages of using make clean are:

  1. Keeps abstraction of the C code compilation separate from the Python.
  2. Gives a better template/example for more complex use cases (if you were testing against a more complicated compilation that generated a bunch of object files, you'd want your make clean to remove all those .o files -- that would make more sense than doing that in Python).

@sroet sroet requested a review from dwhswenson August 27, 2021 15:27
# proc = psutil.Popen("make clean", cwd=engine_dir, shell=True)
# proc.wait()
# Delete compilation files
proc = psutil.Popen(["make", "clean"], cwd=engine_dir)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has to be a list to be able to run without a shell (which we should default to), otherwise you will get the error:

FileNotFoundError: [Errno 2] No such file or directory: 'make clean'

@dwhswenson dwhswenson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sroet sroet merged commit 9a666ff into openpathsampling:master Aug 29, 2021
@sroet sroet deleted the fix_external_engine_teardown branch August 29, 2021 08:18
@dwhswenson dwhswenson mentioned this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants