-
Notifications
You must be signed in to change notification settings - Fork 21
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
Further test improvements #9
Conversation
Fiwo735
commented
Feb 6, 2024
•
edited
Loading
edited
- Improved Python testing, making it the default and recommended testing option.
- Removed duplicated test case (same functionality as _example)
- Updated AST diagram to the new version
@Jpnock please let me know if you have any further suggestions regarding testing. |
Many thanks for updating the diagram : ) I've summarised the differences between the Python and bash script below which should probably be addressed. As for the GitHub Actions issue, this is likely due to there being no terminal TTY available so these code paths need disabling in CI. Python test script differences
GitHub Actions issueI assume a TTY doesn't exist in the actions runtime, so the following line likely returns a non zero exit code. Regardless, the progress bar code should be disabled in GitHub Actions otherwise you get output that looks like
Other notesHave we got a plan for how we're going to update the marking code to fit in with this python script? My concern is that the marking script currently extends the existing At 400 LOC the Python script is much more daunting from the students' perspective to read and understand, so I suggest that we at least move the test_sh.log
test_py.log
test_py_verbose.logscripts/test.py -v > test_py_verbose.log`
|
Is there a point of doing a return code check on |
root@host:~# cd /tmp
root@host:/tmp# mkdir test
root@host:/tmp# cd test/
root@host:/tmp/test# touch abc
normaluser@host:/tmp$ rm -rf test/
rm: cannot remove 'test/abc': Permission denied
normaluser@host:/tmp$ echo "$?"
1 |
…oring when redirecting output
@Jpnock I believe all your suggestions have been addressed through the recent commits. Some remarks:
|
Dockerfile
Outdated
# Install Python packages | ||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir colorama | ||
|
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.
Is there a way we can avoid this? I'm not the biggest fan of getting people to rebuild their container after they've already started. If needed, move to the end of the Dockerfile such that the rest of the layers will likely be cached, making rebuilding much shorter.
Additionally, we should likely be tracking any dependencies in a requirements.txt
file
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.
Good point. The reason for colorama
is that it's a portable (hopefully covers all systems students might want to use) and light-weight way of printing in colour, much better than directly emitting the special exit codes (\033...
etc.) and likely less confusing for those trying to understand test.py
.
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'm slightly in favor of holding off with requirements.txt
until we have more than 1 dependency - while it's obviously a better solution, for now the current way (hopefully) seems more straightforward for students.
scripts/test.py
Outdated
import shutil | ||
import subprocess | ||
import queue | ||
from pathlib import Path | ||
from concurrent.futures import ThreadPoolExecutor, as_completed | ||
from typing import List, Optional | ||
from colorama import init, Fore |
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.
Is there a special reason for needing this library? If not then I think removing this simplifies a bunch of things and wouldn't require everyone to rebuild their docker image or manually install the library before their test script starts working again.
Not sure what it's for, so just speculating: If this is for trying to get this to work inside Actions CI, just check on sys.stdout.isatty()
instead and don't initialise the progress bar if there's no tty.
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.
[reason for colorama
explained in other comment]
sys.stdout.isatty()
sounds better that the current way with try... except
in main()
when constructing ProgressBar
, but is it as safe in your opinion @Jpnock?
) | ||
return e.returncode | ||
except subprocess.TimeoutExpired as e: | ||
print(f"{e.cmd} took more than {e.timeout}") |
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.
fail_testcase is not called here
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.
What do you exactly mean here @Jpnock?
Thanks for the changes :) I've replied with some follow up comments which are hopefully useful Also, just a note on your previous point: |
Thanks for the suggestions! I've left 3 comments unresolved - please have a look at them. Re: splitting |