serenity icon indicating copy to clipboard operation
serenity copied to clipboard

LibTest: Return 0 if all test cases pass and 1 otherwise from TEST_MAIN

Open ronak69 opened this issue 1 year ago • 0 comments

    Before, TEST_MAIN used to return the return value of TestSuite::main()
    function (which returns the number of test cases that did not pass, so
    it can be >=256) directly.

    The run-tests utility determines the success / failure of a test suite
    binary by examining its (or i.e. TEST_MAIN's) exit status.

    But as exit status values are supposed to be between 0 and 255, values
    >=256 will get wrapped around (modulo 256), converting a return value of
    256 to 0.

    So, in a rare case where exactly 256 test cases are failing in your test
    suite, run-tests utility will display that the test suite passed without
    any failures.

    Now, TEST_MAIN just returns 0 if all of the test cases pass and returns
    1 otherwise.

ronak69 avatar Feb 08 '24 22:02 ronak69