-
Notifications
You must be signed in to change notification settings - Fork 53
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
Create run_tests.py #113
base: main
Are you sure you want to change the base?
Create run_tests.py #113
Conversation
I am having trouble with the following error when I run my code:
|
That means you don't have pyfrc or other programs installed. What did you install? |
Here is my pip list:
|
run_tests.py
Outdated
def main(): | ||
current_directory = Path(__file__).parent | ||
for x in current_directory.glob("./**/robot.py"): | ||
os.system(f"cd {x.parent}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use os.system
, use subprocess.run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the change directory or instead of all os.system calls? Is it allowed to use the os library at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... I didn't actually even notice that you were calling cd
. Don't do that either, specify cwd
argument to subprocess.run
.
os.system
should generally be avoided.
run_tests.py
Outdated
current_directory = Path(__file__).parent | ||
for x in current_directory.glob("./**/robot.py"): | ||
os.system(f"cd {x.parent}") | ||
os.system("python -m robotpy sync") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use python
, use sys.executable
# Which extra RobotPy components should be installed | ||
# -> equivalent to `pip install robotpy[extra1, ...] | ||
robotpy_extras = [ | ||
# "all", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list might change over time, so I'm inclined to have it be robotpy_extras = []
?
@@ -0,0 +1,102 @@ | |||
#!/usr/bin/env python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would want to remove the existing run_tests.sh and run this script instead in CI? And remove the stuff from CI that does installation, since this script would do that in the virtualenv?
run_tests.py
Outdated
import sys | ||
from pathlib import Path | ||
|
||
import robotpy.main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was experimenting to see if I could access the robotpy installer through the library
run_tests.py
Outdated
print(BASE_TESTS) | ||
if manipulatedPath in BASE_TESTS: | ||
os.chdir(x.parent) | ||
os.system(f"{sys.executable} -m robotpy sync") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to want to make a clean virtualenv for each one of these tests and do the sync/run in that.
This code was written at work where my proxy blocks the venv pip installer from working so I haven't tested this code. I have just worked on it to test at home later. I added an enviromentBuilder class. I also changed the os.system to subprocess.run
Working on creating run_tests.py and creating a toml file for each folder as per #112