Skip to content
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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

Suave101
Copy link
Contributor

Working on creating run_tests.py and creating a toml file for each folder as per #112

@Suave101
Copy link
Contributor Author

I am having trouble with the following error when I run my code:

__main__.py: error: No entry points defined -- robot code can't do anything. Install packages to add entry points (see README)

@virtuald
Copy link
Member

I am having trouble with the following error when I run my code:

__main__.py: error: No entry points defined -- robot code can't do anything. Install packages to add entry points (see README)

That means you don't have pyfrc or other programs installed. What did you install?

@Suave101
Copy link
Contributor Author

Here is my pip list:

Package                   Version
------------------------- ----------
attrs                     21.4.0
bcrypt                    4.1.2
bleach                    3.3.0
certifi                   2020.12.5
cffi                      1.16.0
chardet                   4.0.0
click                     8.1.7
colorama                  0.4.4
cryptography              41.0.7
decorator                 4.4.2
docutils                  0.17
exceptiongroup            1.2.0
idna                      2.10
imageio                   2.33.1
imageio-ffmpeg            0.4.7
importlib-metadata        7.0.1
iniconfig                 2.0.0
jsonschema                4.4.0
kconfiglib                14.1.0
keyring                   23.0.1
moviepy                   1.0.3
numpy                     1.26.3
opencv-python             4.9.0.80
packaging                 23.2
paramiko                  3.4.0
phoenix6                  24.1.0
pillow                    10.2.0
Pint                      0.23
pip                       23.3.1
pkginfo                   1.7.0
pluggy                    1.3.0
proglog                   0.1.10
pycparser                 2.21
pyfrc                     2024.0.1
pygame                    2.1.2
Pygments                  2.8.1
PyNaCl                    1.5.0
pynetconsole              2.0.4
pyntcore                  2024.2.1.1
pyrsistent                0.18.1
pytest                    7.4.4
pytest-reraise            2.1.2
pytube                    12.1.0
pywin32-ctypes            0.2.2
readme-renderer           29.0
requests                  2.25.1
requests-toolbelt         0.9.1
rfc3986                   1.4.0
robotpy                   2024.2.1.0
robotpy-apriltag          2024.2.1.1
robotpy-cli               2024.0.0
robotpy-commands-v2       2024.0.0b4
robotpy-cscore            2024.2.1.1
robotpy-ctre              2024.1.1
robotpy-hal               2024.2.1.1
robotpy-halsim-ds-socket  2024.2.1.1
robotpy-halsim-gui        2024.2.1.1
robotpy-halsim-ws         2024.2.1.1
robotpy-installer         2024.1.3
robotpy-navx              2024.1.0
robotpy-pathplannerlib    2024.1.3
robotpy-playingwithfusion 2024.0.0
robotpy-rev               2024.2.0
robotpy-romi              2024.2.1.1
robotpy-wpilib-utilities  2024.0.0
robotpy-wpimath           2024.2.1.1
robotpy-wpinet            2024.2.1.1
robotpy-wpiutil           2024.2.1.1
robotpy-xrp               2024.2.1.1
setuptools                68.2.2
six                       1.15.0
tomli                     2.0.1
tqdm                      4.60.0
twine                     3.4.1
typing_extensions         4.9.0
urllib3                   1.26.4
webencodings              0.5.1
wheel                     0.41.2
wpilib                    2024.2.1.1
zipp                      3.4.1

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}")
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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")
Copy link
Member

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",
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

Hm?

Copy link
Contributor Author

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")
Copy link
Member

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants