ztombol / bats-file

Common filesystem assertions for Bats
Creative Commons Zero v1.0 Universal
51 stars 50 forks source link

macOS Support #3

Open ELLIOTTCABLE opened 7 years ago

ELLIOTTCABLE commented 7 years ago

So, this appears to not work at all on OS X (due to BSDs' differences w.r.t. several command-line APIs):

After first installing and adding to my setup(), I got errors like this:

> jxa-async@0.0.1 test /Users/ec/Dropbox/Code/jxa-async
> bats ./test/*.bats

 ✗ Browserify successfully bundles jxa-async
   (from function `setup' in file test/common.bash, line 24,
    from function `bats_test_begin' in file node_modules/bats/libexec/bats-exec-test, line 87,
    in test file test/browserify.bats, line 3)
     `@test "Browserify successfully bundles jxa-async" {' failed

   -- ERROR: temp_make --
   mktemp: illegal option -- -
   usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
          mktemp [-d] [-q] [-u] -t prefix 
   --

   -- ERROR: temp_del --
   rm: No such file or directory
   --

After subsequently cloning bats-file and running its own tests with bats test, I'm seeing a failure on every single test.

(I believe Travis has macOS systems you can add to your build-matrix to ensure this continues to function on Macs!)

ELLIOTTCABLE commented 7 years ago

Mind you, I have no idea why the tests for assert_file_exist etc are failing as well — let me know if you want me to change anything and re-execute.

mlopes commented 7 years ago

I can confirm I'm having the same error, I'm running my tests on travis, so the output can be seen here:

https://travis-ci.org/mlopes/git-.f/jobs/242817125

this is caused only by tmp_make, the assert_file_exists and assesrt_file_no_exists work.

It looks like the OSX version of mktemp doesn't support -- I wonder if there's an alternative way to do it, or if we could just specify a different command when running on OSX

EDIT:

I now have access to an OSX, and could confirm that --directory only works as -d on OSX/BSD, this one should be easy to fix as it also works on Linux. But also --tmpdir doesn't exist on OSX/BSD, there's a -t, but I can't figure out if it does the same thing, as the description for either of them is quite ambiguous.

Also the - in the template doesn't seem to work, I get the message mktemp: illegal option -- X

mlopes commented 7 years ago

I could try to fix it and make a PR, but not sure if it's worth it as I see PRs pending from a few months ago. Is this project still maintained?

ztombol commented 7 years ago

@mlopes I apologise for the hiatus. I've been moving and starting a new job. As soon as things quiet down a little bit, I'm planning to get back to working on bats and the bats-* libraries. Unfortunately, I can't provide an ETA, but I promise I'll be back as soon as my schedule allows. :slightly_smiling_face:

ELLIOTTCABLE commented 7 years ago

@ztombol, if you feel like giving someone commuter status, I’d be happy to try and maintain a ‘develop’ branch, merging some work on things like this, until you return

mlopes commented 7 years ago

A deeper look into this seems to indicate that one of the problems is that this:

local template="$prefix"
  template+="${BATS_TEST_FILENAME##*/}"
  template+="-${BATS_TEST_NUMBER}"
  template+='-XXXXXXXXXX'

ends up as '-XXXXXXXXXX' on OSX somehow, and then it gives me the -- X error even if I do an [ if uname -s = 'Darwin' ] and pass the correct parameters for OSX, if I try using that string as template on Linux, I get the exact same error.

mlopes commented 7 years ago

Made a pull request fixing this (#4)