core: Improve test error messages when files not found

This commit is contained in:
Tom Henderson
2025-01-14 14:55:13 -08:00
parent 6bac519b7a
commit c0ccc9cbff
2 changed files with 15 additions and 6 deletions

View File

@@ -14,6 +14,7 @@
#include "ascii-file.h"
#include "test.h"
#include <filesystem>
#include <stdint.h>
/**
@@ -28,11 +29,19 @@
do \
{ \
uint64_t line(0); \
bool diff = AsciiFile::Diff(gotFilename, expectedFilename, line); \
NS_TEST_EXPECT_MSG_EQ(diff, \
false, \
"ASCII traces " << gotFilename << " and " << expectedFilename \
<< " differ starting from line " << line); \
bool fileExists = std::filesystem::exists(expectedFilename); \
if (fileExists) \
{ \
bool diff = AsciiFile::Diff(gotFilename, expectedFilename, line); \
NS_TEST_EXPECT_MSG_EQ(diff, \
false, \
"ASCII traces " << gotFilename << " and " << expectedFilename \
<< " differ starting from line " << line); \
} \
else \
{ \
NS_TEST_EXPECT_MSG_EQ(fileExists, true, "File " << expectedFilename << " not found"); \
} \
} while (false)
#endif /* ASCII_TEST_H */

View File

@@ -122,7 +122,7 @@ ExampleAsTestCase::DoRun()
if (m_shouldNotErr)
{
// Make sure the example didn't outright crash
NS_TEST_ASSERT_MSG_EQ(status, 0, "example " + m_program + " failed");
NS_TEST_ASSERT_MSG_EQ(status, 0, "example " + m_program + " exited abnormally");
}
// If we're just introspecting the command-line