getmoro/moro

Can't run tests on macOS

mccraveiro opened this issue · 5 comments

Hi!

I'm trying to run all tests on a macOS but I got the following error:

faketime: command not found

Then I've installed faketime with brew install libfaketime and tried to run again.
Unfortunately I got another error:

Timestamp to fake not recognized, please re-try with a different timestamp.

Which version of faketime is the project using?
It would be nice to have these instructions on readme :)

Thank you!

It was missing coreutils!
Installed it with brew install coreutils but some tests are still failing.

It seems that faketimer is not working properly :/

Example:

✗ moro with no argument, first time should register clock in, and calculate clock out accordingly
   (from function `assert_contains' in file tests/end-to-end/../../node_modules/bats-assert/all.bash, line 63,
    from function `assert_output_contains' in file tests/end-to-end/../../node_modules/bats-assert/all.bash, line 98,
    in test file tests/end-to-end/moro.tests.bats, line 22)
     `assert_output_contains 'You clocked in at: 08:00'' failed
   expected:   
    💙  Moro \o/
   
   ✔ You clocked in at: 23:54
   
   
   ⏰ Working until 08:24 will make it a full (8 hours) day
   
   
   ℹ Tip: next time you run moro, you will clock out!
   to contain: You clocked in at: 08:00

Oh sorry to hear that.
I checked libfaketime and seems like there are some issues with macos https://github.com/wolfcw/libfaketime/issues

also this post: https://stackoverflow.com/questions/9059314/alternate-system-time-for-an-application

I don't have a mac to confirm, but if it proves to be impossible on macos, we need to find an alternative.

@omidfi It seems that faketime won't work with OSX System Integrity Protection enabled (and it doesn't seem like a good idea disabling it).

Is it possible to Unit test it instead?

@mccraveiro There are unit tests in tests/db-tests.js, but at some point, they failed to catch a very obvious bug and we released something that didn't work. That's why we switched to end-to-end tests.

If someone is up for it, this test can be done without faking time, it probably needs some bash magic to get the current time, and do the math on it, instead of on the fake time.

By the way, the CI runs all the tests, so by sending a pull request, you can find out if you have broken something.

I'll close this, feel free to reopen.