From 92d43c62ea6ca4164fefe82b2255b70e4172c96a Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 25 Jul 2023 02:21:36 +0000 Subject: [PATCH 1/3] Adds a warning if the `Server` method of a `TestFixture` is called before `Finalize This commit adds a warning if someone were to call `Server()` before `Finalize`. The rationale for this is because I made the mistake of not calling `Finalize` ina program I was writing. It took me some time to track down the root cause of the problem. I figure if we warn users it should be immediately obvious. Signed-off-by: Arjo Chakravarty --- src/TestFixture.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/TestFixture.cc b/src/TestFixture.cc index 7e05455ed2..0b6e90a258 100644 --- a/src/TestFixture.cc +++ b/src/TestFixture.cc @@ -210,6 +210,13 @@ TestFixture &TestFixture::OnPostUpdate(std::function TestFixture::Server() const { + if (!this->dataPtr->finalized) + { + ignwarn << "Fixture has not been finalized, any functions you attempted" + << "to hook into will not be run. It is recommended to call Finalize()" + << "before accessing the server." + << std::endl; + } return this->dataPtr->server; } From c5471e5f7b874a3157b5dc74c9875402233322f9 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 26 Jul 2023 00:31:26 +0000 Subject: [PATCH 2/3] switch to gzwarn over ignwarn Signed-off-by: Arjo Chakravarty --- src/TestFixture.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestFixture.cc b/src/TestFixture.cc index 0b6e90a258..4568d010f7 100644 --- a/src/TestFixture.cc +++ b/src/TestFixture.cc @@ -212,7 +212,7 @@ std::shared_ptr TestFixture::Server() const { if (!this->dataPtr->finalized) { - ignwarn << "Fixture has not been finalized, any functions you attempted" + gzwarn << "Fixture has not been finalized, any functions you attempted" << "to hook into will not be run. It is recommended to call Finalize()" << "before accessing the server." << std::endl; From eb4dc9fc3b6b38de297039ca22c67e958884b860 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 26 Jul 2023 01:03:53 +0000 Subject: [PATCH 3/3] ignwarn cause citadel :( Signed-off-by: Arjo Chakravarty --- src/TestFixture.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestFixture.cc b/src/TestFixture.cc index 4568d010f7..0b6e90a258 100644 --- a/src/TestFixture.cc +++ b/src/TestFixture.cc @@ -212,7 +212,7 @@ std::shared_ptr TestFixture::Server() const { if (!this->dataPtr->finalized) { - gzwarn << "Fixture has not been finalized, any functions you attempted" + ignwarn << "Fixture has not been finalized, any functions you attempted" << "to hook into will not be run. It is recommended to call Finalize()" << "before accessing the server." << std::endl;