jgigault / 42FileChecker

42FileChecker is a tiny bash script developed at 42 school for testing and checking files according to the rules of the subjects
Apache License 2.0
306 stars 56 forks source link

get_next_line moulitest implementation bug #139

Open tobyhw opened 5 years ago

tobyhw commented 5 years ago

I am getting different results running moulitest directly and running it through the 42FileChecker. I found that this is because in moulitest, they test get_next_line(1, NULL) line 10 in 05_test_error_handling.spec.c

However, since 42FileChecker redirects the stdout (1) when it calls moulitest (make "$1" -C "${MOULITEST_DIR}" 1> .mymoulitest 2>&1 in external_repository_moulitest.sh) the read in this test will always fail, so checking the NULL pointer protection does not work.

To test that this is indeed the problem, I changed line 10 in moulitest to run get_next_line(0, NULL) instead and got the desired result, though it was slower because it waited for standard input that never came.

I do not know if there is a way you could manage this from within 42FileChecker without changing moulitest, but if not, it may be worth implementing a test for a NULL pointer in your own tests. In my opinion, the ideal thing would be to test the NULL pointer with an fd that does exist and would otherwise return correctly.

jgigault commented 5 years ago

Hello @tobyhw

Sorry for my (very) late answer.

Could you provide me a working example of the observed behavior? I am not in capacity to reproduce a differing behavior between moulitest "standalone" and moulitest "within 42FC"