rpi-gpio.js icon indicating copy to clipboard operation
rpi-gpio.js copied to clipboard

Hardware checks

Open julienvincent opened this issue 9 years ago • 5 comments

This pull requests adds some basic hardware and platform checks. First check is wether or not to require epoll, and the second check is wether or not the system is running on a raspberry pi.

The reason I added these checks is to improve development experience. With these checks in place, the module doesn't break the application it is being used in if the development environment isn't a raspberry pi.

Some tests are failing and I would appreciate it if you could try get them passing again. I haven't had enough time to do that yet.

Cheers

julienvincent avatar Jan 12 '16 11:01 julienvincent

Hi, thanks for the patch and I'm happy to help with the tests, but just to warn you it may be a few months before I can spare the time unfortunately, and I have no access to my Raspberry Pis at present. I'm hoping I can at least have a go at the tests before then. Cheers.

JamesBarwell avatar Jan 14 '16 15:01 JamesBarwell

I'll give a go at the tests sometime tomorrow and see if I can get them passing.

julienvincent avatar Jan 14 '16 21:01 julienvincent

As you can see in the log, the test's are not passing because the Travis CI environment obviously isn't a raspberry pi.

Maybe a easy fix would be to add a option to force requiring epoll and such, even if not on a raspberry pi. Then in the test that option could be used.

simonmeusel avatar Jan 19 '18 17:01 simonmeusel

At the moment the tests are written to stub/mock out their dependencies. I want to stick to this approach because it means we can test all of the module code, and assert on how it interacts with those dependencies. I don't want to get into a situation where flags are used to make the module execute a separate code path when it is under test.

The tests do pass on Travis on the master branch so there is no inherent problem with this approach.

I can't remember exactly where we are with this PR but I'm not sure that it's needed now. The tests do run in a non-RPI environment because Epoll does get stubbed out correctly. I do all my dev on non-RPI hardware using the test suite. If anyone is having problems then raise another issue and let's discuss the options

JamesBarwell avatar Jan 22 '18 14:01 JamesBarwell

Generally test do past with your approach, but this PR (which is in my opinion very important) add a hardware check. That check obviously detects the travis environment. Thus only that initial check needs to be removed for the tests.

simonmeusel avatar Jan 22 '18 16:01 simonmeusel