Tarrasch / zsh-autoenv

Autoenv for zsh
693 stars 30 forks source link

Fix issues with running tests on macOS #76

Closed rspeed closed 6 years ago

rspeed commented 6 years ago

More of a reminder to myself.

In short: The tests assume that mktemp generates everything under /tmp, but that isn't the case on macOS. So… gotta fix that.

blueyed commented 6 years ago

Good point. Where is it created for you? Probably only the expected globs need to be adjusted?!

rspeed commented 6 years ago

It's a random directory created at login under /var/folders/fw/. Right now for me it's /var/folders/fw/hgtkrd7x4kvgxmlp5j3n31780000gn/T/. I think the solution is to compare the path against $TMPDIR, rather than assuming it's /var/tmp.

blueyed commented 6 years ago

https://github.com/Tarrasch/zsh-autoenv/pull/78 should fix it, can you try it? (assuming that Travis likes it)

There is $CRAMTMP, but it cannot be used in the expected output (AFAIK).

rspeed commented 6 years ago

Seems like it! Though I'm still not able to get the tests to run… it's as though autoenv.zsh isn't being sourced. Do you have instructions for running the tests?

rspeed commented 6 years ago

Disregard that. I looked at .travis.yml and noticed that it needs a couple of environmental variables. Most of the tests are passing now, except for tests/recurse-upwards.t. Looking into it.

rspeed commented 6 years ago

I'm not quite sure. May not be a platform issue. This is what I get from ZDOTDIR=tests/ZDOTDIR make:

cram --shell=zsh -v tests
tests/_autoenv_stack.t: passed
tests/_autoenv_utils.t: passed
tests/autoenv-edit.t: passed
tests/autoenv.t: passed
tests/cwd.t: passed
tests/leave.t: passed
tests/recurse-upwards.t: failed
--- tests/recurse-upwards.t
+++ tests/recurse-upwards.t.err
@@ -77,9 +77,7 @@
   $ test_autoenv_auth_env_files

   $ cd .
-  autoenv_source_parent_from_sub:
-  ENTERED_root: PWD:sub from:sub to:sub
-  ENTERED_sub: PWD:sub from:sub to:sub
+  autoenv_source_parent_from_sub:nautoenv_source_parentnecho ENTERED_sub: PWD:sub from:sub to:sub
   ENTER2
   done_sub

@@ -90,9 +88,7 @@
   $ test_autoenv_add_to_env sub2/.autoenv.zsh
   $ cd sub2
   autoenv_source_parent_from_sub2:
-  autoenv_source_parent_from_sub:
-  ENTERED_root: PWD:sub2 from:sub to:sub2
-  ENTERED_sub: PWD:sub2 from:sub to:sub2
+  autoenv_source_parent_from_sub:nautoenv_source_parentnecho ENTERED_sub: PWD:sub2 from:sub to:sub2
   ENTER2
   done_sub
   done_sub2
@@ -113,18 +109,7 @@
   $ echo "echo NEW" >| .autoenv.zsh
   $ _autoenv_ask_for_yes() { echo "no"; return 1 }
   $ cd sub
-  autoenv_source_parent_from_sub:
-  Attempting to load unauthorized env file!
-  -* /*/cramtests-*/recurse-upwards.t/.autoenv.zsh (glob)
-  
-  **********************************************
-  
-  echo NEW
-  
-  **********************************************
-  
-  Would you like to authorize it? (type 'yes') no
-  ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub
+  autoenv_source_parent_from_sub:nautoenv_source_parentnecho ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub
   ENTER2
   done_sub

@@ -138,7 +123,13 @@

   $ touch -t 201401010104 .autoenv.zsh
   $ cd .
-  autoenv_source_parent_from_sub:
+  autoenv_source_parent_from_sub:nautoenv_source_parentnecho ENTERED_sub: PWD:sub from:sub to:sub
+  ENTER2
+  done_sub
+
+
+  $ cd ..
+  LEFT_sub: PWD:recurse-upwards.t from:sub to:recurse-upwards.t
   Attempting to load unauthorized env file!
   -* /*/cramtests-*/recurse-upwards.t/.autoenv.zsh (glob)

@@ -150,19 +141,10 @@

   Would you like to authorize it? (type 'yes') yes
   NEW
-  ENTERED_sub: PWD:sub from:sub to:sub
-  ENTER2
-  done_sub
-
-
-  $ cd ..
-  LEFT_sub: PWD:recurse-upwards.t from:sub to:recurse-upwards.t
   $ mkdir sub/sub2/sub3
   $ cd sub/sub2/sub3
   autoenv_source_parent_from_sub2:
-  autoenv_source_parent_from_sub:
-  NEW
-  ENTERED_sub: PWD:sub3 from:recurse-upwards.t to:sub3
+  autoenv_source_parent_from_sub:nautoenv_source_parentnecho ENTERED_sub: PWD:sub3 from:recurse-upwards.t to:sub3
   ENTER2
   done_sub
   done_sub2
tests/source-parent-until.t: passed
tests/source-parent-vars.t: passed
tests/upgrade_hash.t: passed
tests/varstash-alias.t: passed
tests/varstash-unstash-on-leave.t: passed
tests/varstash.t: passed
tests/varstash_export.t: passed
# Ran 14 tests, 0 skipped, 1 failed.
rspeed commented 6 years ago

Okay, I'm pretty sure this is also a platform issue. There are some differences in sed between FreeBSD and GNU Coreutils.

Edit: Yup, pretty sure this is the issue. On Linux sed replaces the \n with actual newlines, but on macOS it doesn't.

rspeed commented 6 years ago

Aaaaaand this is really annoying because the standard solution would be to use actual newlines, but then cram errors out because you can't have multiline commands. Argh.