diff options
| author | Stefan Boberg <[email protected]> | 2021-09-20 10:15:12 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-20 10:15:12 +0200 |
| commit | 8d3024a7e09246e44bf6d9ea14a36e6b03032e85 (patch) | |
| tree | c18c2536d108378e5cddcac21398efd8d28e437d /zen/zen.cpp | |
| parent | Added testing.h to wrap doctest.h (diff) | |
| download | archived-zen-8d3024a7e09246e44bf6d9ea14a36e6b03032e85.tar.xz archived-zen-8d3024a7e09246e44bf6d9ea14a36e6b03032e85.zip | |
It's not possible to compile out tests
Tests are now compiled in if `ZEN_WITH_TESTS=1`, and compiled out if not. Compiling tests out reduces the footprint of the resulting executables quite significantly.
Diffstat (limited to 'zen/zen.cpp')
| -rw-r--r-- | zen/zen.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/zen/zen.cpp b/zen/zen.cpp index 9c373face..00505be75 100644 --- a/zen/zen.cpp +++ b/zen/zen.cpp @@ -1,9 +1,7 @@ // Zen command line client utility // -#define DOCTEST_CONFIG_IMPLEMENT -#include <doctest/doctest.h> -#undef DOCTEST_CONFIG_IMPLEMENT +#include <zencore/zencore.h> #include "zen.h" @@ -23,17 +21,10 @@ #include <zencore/string.h> #include <zenstore/cas.h> -#if TEST_UWS -# pragma warning(push) -# pragma warning(disable : 4458) -# pragma warning(disable : 4324) -# pragma warning(disable : 4100) -# pragma warning(disable : 4706) -# include <uwebsockets/App.h> -# pragma warning(pop) - -# pragma comment(lib, "Iphlpapi.lib") -# pragma comment(lib, "userenv.lib") +#if ZEN_WITH_TESTS +# define DOCTEST_CONFIG_IMPLEMENT +# include <zencore/testing.h> +# undef DOCTEST_CONFIG_IMPLEMENT #endif #include <gsl/gsl-lite.hpp> @@ -58,6 +49,8 @@ private: ////////////////////////////////////////////////////////////////////////// +#if ZEN_WITH_TESTS + class RunTestsCommand : public ZenCmdBase { public: @@ -87,6 +80,8 @@ private: cxxopts::Options m_Options{"runtests", "Run tests"}; }; +#endif + ////////////////////////////////////////////////////////////////////////// // TODO: should make this Unicode-aware so we can pass anything in on the // command line. @@ -104,19 +99,22 @@ main(int argc, char** argv) auto _ = zen::MakeGuard([] { spdlog::shutdown(); }); - HashCommand HashCmd; - CopyCommand CopyCmd; - DedupCommand DedupCmd; - DeployCommand DeployCmd; - DropCommand DropCmd; - ChunkCommand ChunkCmd; + HashCommand HashCmd; + CopyCommand CopyCmd; + DedupCommand DedupCmd; + DeployCommand DeployCmd; + DropCommand DropCmd; + ChunkCommand ChunkCmd; + RunCommand RunCmd; + StatusCommand StatusCmd; + TopCommand TopCmd; + PsCommand PsCmd; + UpCommand UpCmd; + DownCommand DownCmd; + +#if ZEN_WITH_TESTS RunTestsCommand RunTestsCmd; - RunCommand RunCmd; - StatusCommand StatusCmd; - TopCommand TopCmd; - PsCommand PsCmd; - UpCommand UpCmd; - DownCommand DownCmd; +#endif const struct CommandInfo { @@ -131,14 +129,16 @@ main(int argc, char** argv) {"dedup", &DedupCmd, "Dedup files"}, {"drop", &DropCmd, "Drop cache bucket(s)"}, {"hash", &HashCmd, "Compute file hashes"}, - {"runtests", &RunTestsCmd, "Run zen tests"}, {"run", &RunCmd, "Remote execution"}, {"status", &StatusCmd, "Show zen status"}, {"ps", &PsCmd, "Enumerate running zen server instances"}, {"top", &TopCmd, "Monitor zen server activity"}, {"up", &UpCmd, "Bring zen server up"}, {"down", &DownCmd, "Bring zen server down"}, - // clang-format on + // clang-format on +#if ZEN_WITH_TESTS + {"runtests", &RunTestsCmd, "Run zen tests"}, +#endif }; // Build set containing available commands |