-
Notifications
You must be signed in to change notification settings - Fork 392
Running tests on Windows #4099
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
Running tests on Windows #4099
Conversation
- Be sure to deactivate Quarto env var that forces PYTHON to overwrite local config - Use `py.exe` because in `venv` the `exe` do not work somehow.
|
I would like to note that this is an extremely exciting PR. |
We duplicate the step in the `run-test` script, but it is better to have this setup before installing quarto-dev in next step
* Using tmate * Deactivating other workflow as not useful when debugging
2ad731a to
3bb301a
Compare
5bd3c31 to
f2237ee
Compare
|
This is now ready for integration. I just launched a last test with the latest change from main. All tests passes except 2 or 3 I think that I ignore for now until we fixe them. There are quite a few changes for local environment so it is worth reading and checking before we merge. A README is available to explain. This PR
Hopefully the change will work for everyone local environment. Limitation and what to do nextCurrently we rely on testing our code with locked state of packages for Julia, R and Python. This is using tools that will rely on lockfile to recreate a fix state. This means that we'll need to update the different lockfile on regular basis - I should add a note in the README probably Making it possible to test with latest version of all packages will be next in line among test environment improvment. |
|
@dragonstyle putting you as reviewer as you seemed to be available and interested to test all this locally together. |
this will save us some time on workflow
tests/run-tests.sh
Outdated
| # Ensure that tinytex is installed | ||
| quarto install tinytex --no-prompt | ||
| # Activating python virtualenv | ||
| if [[ -z $VIRTUAL_ENV ]] |
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.
if [[ -z $FORCE_NO_PIPENV ]]
then
OLD_VIRTUAL_ENV=$VIRTUAL_ENV
if [[ -n $VIRTUAL_ENV ]]
then
deactivate
end
echo "> Activating virtualenv for Python tests"
source "$(pipenv --venv)/bin/activate"
quarto_venv_activated="true"
end
# ...
# at the end
# this is probably not correct if we were not in a venv but you get the idea.
if [[ -n $OLD_VIRTUAL_ENV ]]
then
deactivate
source $OLD_VIRTUAL_ENV/bin/activate
end
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.
So I did another approach as deactivating was not robust. For example I am using pyenv on Linux to manage my python and virtualenv and deactivate was not existing.
So I leveraged some pipenv feature. Here is how it works
pipenvwill always create a virtual environment even when run in another virtuaenv. This means by default it will activate the new virtualenv. This environment will be located intests/.venv- If I detect that $VIRTUAL_ENV is set though before activating with pipenv, I remember this, and at the end, I run
source $OLD_VIRTUAL_ENV/bin/activateto reactivate the initial virtualenvironment. - To skip the default behavior
QUARTO_TESTS_FORCE_NO_PIPENVcan be set to any value. In that case, tests are running in the current python environment with no change.
I believe this work well and answer our discussion.
|
Thanks @cscheid and @dragonstyle - I'll still have some last adjustments as discussed today with you both, and this will be ready to merge tomorrow ! 🎉 So cool ! |
…virtualenv shell This relies on pipenv features to ignore virtualenv and create a new one. Add a mechanism to skip using pipenv
|
I did the modification for the virtual environment, and added some information to the documentation. Ready now to merge ! |
|
Feel free to merge anytime! |
WIP: Draft PR until it is working
run-test.shto arun-test.ps1version./configure.cmdshould run on CI - adapt our customquarto-devactionrenvactivation when running tests (issue)notebook-viewappends URL to figure path somewhere and this error on Windows #4337Follow up work
The following are related to ignored tests on Windows and should be fixed
Adaptations
./tests/bin/*foldersource bin/activatewere not useful (some hardcoded miniconda path in it). Removing it seems to work ok..python_versionfile to pin a python version to use intests/setup-pythonpyenvto automically use the right version of python in when intests/quarto-devwhich install quarto development versionquarto.cmd, which is not found in PATH on windows'sbash. Usingcmdshell is a pain as it seems you can't really set%GITHUB_PATH%on GHA (🤷♂️ ). So for now, it is hardcoded path but won't probably change soon. Anyway it is working now.Probably some more to change
We are setting up environment in GHA in some steps, but we are also doing
renv::restore()andpip installin therun-test. It seems a duplication. I am thinking of separatingconfig-tests-envscript for configure a test environment, and then havingrun-testto just run the test. But still need to think through CI usage vs Local usage.Having a
quarto.ps1instead ofquarto.cmdwould be better for dev windows user. I never used CMD, and other windows dev probably use either Powershell or Git Bash.Notes on developing tests for Linux and windows
quartoneeds to be explicitly made toquarto.cmdon Windows because in dev versionquarto.exeis not available andquartowithout extension will not be found (6be8232)/vs\9f37289)More comments to come as I go through with it