zunit
zunit copied to clipboard
`run` doesnt maintain state between runs
Hopefully this isnt another non-issue, but using run
doesnt seem to maintain it's environment between subsequent calls in the same test.
e.g.
@test 'something' {
echo "hello" > "foo/bar"
run cd foo
run cat bar
}
the second run will fail because the cd to foo is not maintained
Yep, that's intended bahaviour - the run
helpers runs the command in a subprocess in isolation, purely so that the $output
and $state
can be asserted against. To do something like the above, you'd be better off with one of the following options:
# Call the full path firectly
run cat foo/bar
# Or, if the cd is absolutely necessary, run it in the main
# test scope, so that it affects the test process, and is not
# run in an isolated subprocess
cd foo
run cat bar
In my case the second option seems necessary as cd'ing to the directory is part of the test (this is for testing https://github.com/MichaelAquilina/zsh-autoswitch-virtualenv).
However, for some reason the cd fails without any good reason. I am guessing this is more to do with what my plugin is doing than zunit so I feel like I need to dig into this more.
Is it the master branch which is failing? I spotted this typo in the @setup function if that helps. It's present in all three test files.
I'll download a copy of that repo when I get home and take a look
That should work, It's a zsh shortcut:
$ echo =virtualenvwrapper.sh
/home/michael/.virtualenvs/zsh-autoswitch-virtualenv/bin/virtualenvwrapper.sh
Its almost equivalent to which
Oh, nice. I hadn't heard of that before. I figured it was a variable assignment
I'm getting errors when I'm running the tests that the virtualenvwrapper.sh
script can't be found. Am I looking at the wrong branch? (This is on master)
TAP version 13
not ok 1 - Failure: changing to a directory without .venv defaults
---
message: __zunit_test_setup:1: virtualenvwrapper.sh not found
severity: fail
...
not ok 2 - Failure: changing to a directory with .venv autoswitches
---
message: __zunit_test_setup:1: virtualenvwrapper.sh not found
severity: fail
...
not ok 3 - Failure: chpwd functions are loaded
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 4 - Failure: _check_venv_path with non-existent path
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 5 - Failure: _check_venv_path with no venv
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 6 - Failure: _check_venv_path with existing venv
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 7 - Failure: _check_venv_path in subdirectory with parent venv
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 8 - Failure: rmvenv with no .venv
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 9 - Failure: rmvenv with existing .venv
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
not ok 10 - Failure: rmvenv with existing .venv with deleted virtualenv
---
message: __zunit_test_setup:2: virtualenvwrapper.sh not found
severity: fail
...
1..10
Have you installed virtualenvwrapper?
pip install virtualenvwrapper
You will probably need to use sudo to install that (or use a python virtualenv)
Ah, that would help. Can you tell I'm not a python guy? 😂
haha no problem! I was away in Germany the past few days so I havent managed to give this a look since we last spoke. Any luck from your side? I will probably try find some time today to try clean this all up
Sorry, I haven't got anywhere with this. I've had a couple of attempts, but I've had no luck getting virtualenvwrapper
itself set up properly in order to run these tests. If you have a Vagrantfile/Dockerfile with an environment where this runs I'd be happy to take another look in that environment.
However, looking at the travis output from the master branch, ZUnit doesn't appear to be doing anything that it's not supposed to. Did the cd
failure that you reference above happen in master
, or another unpublished branch?
I need to give the tests for this project a proper look because i noticed quite a few are passing automatically due to the contains
bug. So better I gather some more information for you first :)