mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
tests: Log exceptions thrown inside of unit tests
This commit is contained in:
parent
cfed682d04
commit
7919318be7
@ -32,18 +32,22 @@ class TestFailedException : public std::exception {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Runs a unit test and reports results
|
// Runs a unit test and reports results
|
||||||
#define TEST(fxn, ...) do { \
|
#define TEST(fxn, ...) do { \
|
||||||
u32 t1 = porting::getTime(PRECISION_MILLI); \
|
u32 t1 = porting::getTime(PRECISION_MILLI); \
|
||||||
try { \
|
try { \
|
||||||
fxn(__VA_ARGS__); \
|
fxn(__VA_ARGS__); \
|
||||||
dstream << "[PASS] "; \
|
dstream << "[PASS] "; \
|
||||||
} catch (...) { \
|
} catch (TestFailedException &e) { \
|
||||||
dstream << "[FAIL] "; \
|
dstream << "[FAIL] "; \
|
||||||
num_tests_failed++; \
|
num_tests_failed++; \
|
||||||
} \
|
} catch (std::exception &e) { \
|
||||||
num_tests_run++; \
|
dstream << "Caught unhandled exception: " << e.what() << std::endl; \
|
||||||
u32 tdiff = porting::getTime(PRECISION_MILLI) - t1; \
|
dstream << "[FAIL] "; \
|
||||||
dstream << #fxn << " - " << tdiff << "ms" << std::endl; \
|
num_tests_failed++; \
|
||||||
|
} \
|
||||||
|
num_tests_run++; \
|
||||||
|
u32 tdiff = porting::getTime(PRECISION_MILLI) - t1; \
|
||||||
|
dstream << #fxn << " - " << tdiff << "ms" << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// Asserts the specified condition is true, or fails the current unit test
|
// Asserts the specified condition is true, or fails the current unit test
|
||||||
|
Loading…
Reference in New Issue
Block a user