-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Test Windows & Mac OSX #224
Conversation
So, here's the complete log of the test suite running on Windows 10, Python 3.6.8 👍 It's almost only "template not found" errors and permission errors following the template ones (trying to remove the destination folder). You don't have to read the whole log, just look at the comments in between. $ poetry run pytest copier tests
============================= test session starts =============================
platform win32 -- Python 3.6.8, pytest-5.4.3, py-1.8.2, pluggy-0.13.1
rootdir: C:\Users\user\copier
plugins: cov-2.10.0, forked-1.1.3, timeout-1.4.1, xdist-1.32.0
collected 113 items
tests\test_answersfile.py .. [ 1%]
tests\test_cleanup.py .. [ 3%]
tests\test_cli.py .. [ 5%]
tests\test_complex_questions.py .... [ 8%]
tests\test_config.py ...F............................ [ 37%]
tests\test_copy.py .FFFFFF..FFFFFF. [ 51%]
tests\test_demo_update_tasks.py F [ 52%]
tests\test_exclude.py .. [ 53%]
tests\test_extra_paths.py .... [ 57%]
tests\test_migrations.py FF [ 59%]
tests\test_minimum_version.py .... [ 62%]
tests\test_normal_jinja2.py . [ 63%]
tests\test_output.py FFFFF [ 68%]
tests\test_prompt.py FFF [ 70%]
tests\test_subdirectory.py ..FFF [ 75%]
tests\test_tasks.py F. [ 76%]
tests\test_templated_prompt.py ............. [ 88%]
tests\test_tools.py ......... [ 96%]
tests\test_updatediff.py FF [ 98%]
tests\test_vcs.py FF [100%] test_invalid_yaml
I'd say it's just the test itself that is wrong because it's using forward slashes. test_copy
The usual "template not found" error. test_copy_repo
The usual permission error. OS error at the end
another OS Error
and the rest of it, template and permission errors
|
There were some formatting issues so here's the text file. |
Thanks! I've seen some errors in code. Stay tuned. |
2c78fbd
to
8a318f4
Compare
MacOS
Must be an encoding issue? The Windows A lot of
The changed line endings could also be the reason why the We also see unicode encode/decore errors in both Windows and MacOS. Maybe some extra environments variables would fix this:
|
OK, I tried that, let's see what the bots say. FTR a possible source of macOS problems: https://www.python.org/dev/peps/pep-0540/#locale-encoding-and-utf-8 |
We still have errors on the EDIT: I see you've added the |
Prettier has an |
For the The thing is, they get the paths by parsing the output of $ git ls-files --stage -- tests/demo/doc/mañana.txt tests/demo/doc/manana.txt
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 tests/demo/doc/manana.txt
100644 5ab9dcdd36df0f76f202227ecb7ae8a5baaa456b 0 "tests/demo/doc/ma\303\261ana.txt" The path they get for the second line is I'll open an issue there. |
Prettier and mixed-line-endings are passing on my workstation, file endings are LF. I guess this really has to be fixed with some git config, to make sure the files are fetched with LF in CI. |
A few more fixes for tests: diff --git a/tests/demo_migrations/copier.yaml b/tests/demo_migrations/copier.yaml
index e363b8b..80dc594 100644
--- a/tests/demo_migrations/copier.yaml
+++ b/tests/demo_migrations/copier.yaml
@@ -4,8 +4,8 @@ _exclude:
- .git
_tasks:
- - "python3 [[ _copier_conf.src_path / 'tasks.py' ]] 1"
- - [python3, "[[ _copier_conf.src_path / 'tasks.py' ]]", 2]
+ - "python [[ _copier_conf.src_path / 'tasks.py' ]] 1"
+ - [python, "[[ _copier_conf.src_path / 'tasks.py' ]]", 2]
_migrations:
# This migration is never executed because it's the 1st version copied, and
diff --git a/tests/demo_migrations/migrations.py b/tests/demo_migrations/migrations.py
index 6c498e0..9d34c33 100755
--- a/tests/demo_migrations/migrations.py
+++ b/tests/demo_migrations/migrations.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
import json
import os
import sys
diff --git a/tests/demo_migrations/tasks.py b/tests/demo_migrations/tasks.py
index 74503ba..9e7b102 100755
--- a/tests/demo_migrations/tasks.py
+++ b/tests/demo_migrations/tasks.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
import os
import os.path
import sys
diff --git a/tests/test_migrations.py b/tests/test_migrations.py
index f53936d..eee41e2 100644
--- a/tests/test_migrations.py
+++ b/tests/test_migrations.py
@@ -100,7 +100,7 @@ def test_pre_migration_modifies_answers(tmp_path_factory):
_migrations:
- version: v2
before:
- - - python3
+ - - python
- -c
- |
import sys, yaml, pathlib
diff --git a/tests/test_output.py b/tests/test_output.py
index 7c7b00c..302d624 100644
--- a/tests/test_output.py
+++ b/tests/test_output.py
@@ -8,7 +8,7 @@ def test_output(capsys, tmp_path):
out, _ = capsys.readouterr()
assert re.search(r"create[^\s]* config\.py", out)
assert re.search(r"create[^\s]* pyproject\.toml", out)
- assert re.search(r"create[^\s]* doc/images/nslogo\.gif", out)
+ assert re.search(r"create[^\s]* doc[/\\]images[/\\]nslogo\.gif", out)
def test_output_pretend(capsys, tmp_path):
@@ -16,7 +16,7 @@ def test_output_pretend(capsys, tmp_path):
out, _ = capsys.readouterr()
assert re.search(r"create[^\s]* config\.py", out)
assert re.search(r"create[^\s]* pyproject\.toml", out)
- assert re.search(r"create[^\s]* doc/images/nslogo\.gif", out)
+ assert re.search(r"create[^\s]* doc[/\\]images[/\\]nslogo\.gif", out)
def test_output_force(capsys, tmp_path):
@@ -27,7 +27,7 @@ def test_output_force(capsys, tmp_path):
assert re.search(r"conflict[^\s]* config\.py", out)
assert re.search(r"force[^\s]* config\.py", out)
assert re.search(r"identical[^\s]* pyproject\.toml", out)
- assert re.search(r"identical[^\s]* doc/images/nslogo\.gif", out)
+ assert re.search(r"identical[^\s]* doc[/\\]images[/\\]nslogo\.gif", out)
def test_output_skip(capsys, tmp_path):
@@ -38,7 +38,7 @@ def test_output_skip(capsys, tmp_path):
assert re.search(r"conflict[^\s]* config\.py", out)
assert re.search(r"skip[^\s]* config\.py", out)
assert re.search(r"identical[^\s]* pyproject\.toml", out)
- assert re.search(r"identical[^\s]* doc/images/nslogo\.gif", out)
+ assert re.search(r"identical[^\s]* doc[/\\]images[/\\]nslogo\.gif", out)
def test_output_quiet(capsys, tmp_path):
The rest of the failures (on my workstation) are only permission errors now, due to temporary file cleaning with
|
New pre-commit-hooks release: https://github.com/pre-commit/pre-commit-hooks/releases/tag/v3.2.0, this should fix the manana issue on Windows 🙂 |
Changed. Also applied diff from #224 (comment).
We're using that since we use prettier AFAIK. Maybe that should be disabled so it's git who handles that? 🤔 Line 3 in 173db40
|
ee1d957
to
c82277d
Compare
c96c63a
to
532a4b3
Compare
Let's see if tests work under windows or mac. Don't fail fast the tests If there's one Python version or OS that fails, I still want to see results for the other matrix runs.
Partially revert 97c75e4.
TODO Get some happy Mac hacker that fixes this for us.
I took a dirty but pragmatic approach on some problems:
Let's see what happens now 😊 |
That is great, and you are completely right, as long as non-unit tests are passing on Linux, this is fine. And skipping the few unit tests not passing on Windows/MacOS is fine as well. If a user of these platforms encounter a related bug, they'll be able to fix it or at least help fix it. Thanks a lot for your work here @yajo 🙂 Now I looked at the two last tests failing on Windows, but cannot see what's happening. There seems to be a failed substitution in the OSError case, and a failure from git to add and commit a modified file in the second case. |
- Ignore errors when executing `shutil.rmtree()`, because it seems like it's common to fail when deleting git repos on Windows, and since these are temp files, we don't really care that much there's garbage left. Any good OS should clean the temp folders automatically. - Always find Jinja templates in `PosixPath` mode. - Ignore `OSError` when trying to enter a possibly git root directory. This is yielded by Windows when the path is a URL and we don't really care about it. - Fix some tests with non-windows hardcoded stuff. - Fix a test that was using a Bash script. Modified to be Python, which should work fine cross-system. - Remove external python dependencies (yaml, plumbum) from test task/migration files. These are available on Linux because it gets the python env from the venv, but on Windows, it uses the main python interpreter and breaks. After all, that's not very important here. - Do not modify EOL in CI. - Use python executable in tests instead of python3. - Update pre-commit versions to include pre-commit/pre-commit-hooks#509. - Disable autorebasing. - Disable pre-commit on CI on Windows. - Require python 3.8 on Windows, where `tempfile` supports autoremoving directories with read-only files.
I have been testing in a Windows VM and I'd say the main problem is that the CI is using Git Bash instead of WSL Bash on Windows, which is weird because it seems like being the opposite case of what rest of the world is saying (see actions/runner-images#1081 (comment)). But, you know what? I give up... 😁 If somebody really wants to use console scripts with deep git features on Windows, he'll be probably using WSL already, which is supposed to make whatever works fine on Ubuntu fine on Windows, so if something fails it's most likely WSL problem and not Copier's... So, finally the workaround will be the same as for that nasty macOS test: disable them. FTR this is the latest action run that failed before skipping those tests. I'm gonna open a couple of issues speaking about these corner cases after the PR is merged, so we give visibility to OS-specific issues, which could happen only on CI or could be happening in the real world, but that will have to be fixed by some voluntary user that really cares about that. 🤷♂️ |
a497532
to
30903f1
Compare
Pip, poetry and pre-commit defaulted to OS-specific cache and venv dirs. This made the caching system less useful on macOS and Windows. Now, all is stored under $PWD/.venv and cached from there. This works fine across different OS. Also, the OS is added to the cache key.
Applying workaround for problem described at actions/cache#315 (comment) that makes the windows build take over 20 minutes. Better to use no cache then.
Let's see if tests work under windows or mac.
Continuation of #213