Opened 7 years ago

Closed 7 years ago

#4807 closed defect (fixed)

Test assertion failures print \n instead of newline

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 23
Component: Core engine Keywords:
Cc: Patch: Phab:D952

Description

Test failures are reported with "\n" written as characters, instead of displaying them as a line break (at least on my platform).

For example:

../../../source/test_setup.cpp:135: Error: Test failed: L"Stack trace:\nTS_TEST_PERFORMANCE@simulation/components/tests/test_Math.js:146:1\n@simulation/components/tests/test_Math.js:158:1\nFunction is slower than it could be: pow with exponent 2 ran for 3284ms, but the compared function ran only for 4013ms."

That makes it ugly to read the tests and hard to work with these messags.

Any assertion failure has the following stack trace:

TS_FAIL called from test_setup.js,
TS_FAIL proxy in source/test_setup.cpp
TS_FAIL defined in libraries/source/cxxtest-4.4/cxxtest/TestSuite.h which parses the JS message string with TS_AS_STRING before calling CxxTest::doFailTest

We see that it's either a bug in cxxtest or how we use it.

cxxtest was introduced in r14817, upgraded to 4.4 in r15667 (2014-08-24), which is the most recent version. In particular ValueTraits.cpp is still the most recent version.

There are now two places where it could be broken:

  1. Removing the escaping in charToString of libraries/source/cxxtest-4.4/cxxtest/ValueTraits.cpp which is called from TS_AS_STRING removes the reported bug on my platform.
  1. The pipe it writes to could be used incorrectly.

The escaped string is passed to failedTest which is defined in libraries/source/cxxtest-4.4/cxxtest/ErrorFormatter.h, unix.h and XmlFormatter.h. TODO: continue looking.

Change History (3)

comment:1 by leper, 7 years ago

cxxtest was introduced in r14817, [...]

You might want to take a look at #2450 that is linked from that revision again ;-)

As for where to look, I suspect you might want to make sure that you actually end up calling the right asString, in CxxTest. I suspect the ValueTraits<const char * const &> specialization might not end up being used as we pass std::wstring to it in the JS-exposed TS_FAIL.

comment:2 by elexis, 7 years ago

Milestone: BacklogAlpha 23
Patch: Phab:D952

Suspected that we might have to pass unix instead of ErrorPrinter in configure_cxxtestgen() of premake4.lua. But it seems it was just a missing conversion Phab:D952.

comment:3 by elexis, 7 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 20292:

Fix string format of the JS test assertion failure following r7259 (cxxtest expects a char* instead of a std::wstring, so newlines were printed as \n characters).

Differential Revision: https://code.wildfiregames.com/D952
Fixes #4807

Note: See TracTickets for help on using tickets.