@@ -33,6 +33,8 @@ constexpr std::unique_ptr<B> makeUniqueDerived(Args... args)
3333 return static_cast <std::unique_ptr<B>>(std::make_unique<T>(args...));
3434}
3535
36+ // @FIXME: File utilities functions should live in services::files namespace
37+
3638using models::OS;
3739using services::IRunner;
3840
@@ -282,7 +284,7 @@ void moveFilesWithExtension(
282284std::string getHttpStatus (const auto & url, const std::size_t maxRetries = 3 )
283285{
284286 auto runner = cloyster::Singleton<IRunner>::get ();
285- auto opts = cloyster::Singleton<services::Options>::get ();
287+ auto opts = cloyster::Singleton<const services::Options>::get ();
286288 if (opts->shouldSkip (" http-status" )) {
287289 LOG_WARN (" Skipping HTTP status check for {}, assuming 200 (reason: "
288290 " --skip=http-status in the command line)" ,
@@ -304,20 +306,35 @@ std::string getHttpStatus(const auto& url, const std::size_t maxRetries = 3)
304306 for (std::size_t i = 0 ; i < maxRetries; ++i) {
305307 header = getHttpStatusInner (url, runner);
306308 LOG_DEBUG (" HTTP status of {}: {}" , url, header);
307- if (!header.starts_with (" 5" )) {
308- LOG_DEBUG (" HTTP {} error, retry {}" , header, i);
309+ if (header.starts_with (" 2" )) {
310+ return header;
311+ } else if (header.starts_with (" 5" )) {
312+ LOG_DEBUG (" HTTP INTERNAL SERVER ERROR {} error, retring ...{}" ,
313+ header, i);
314+ return header;
315+ } else {
316+ LOG_DEBUG (" HTTP {} error, retrying ...{}" , header, i);
309317 return header;
310318 }
311319 }
312320 return header;
313321};
314322
315- [[noreturn]] void abort (const fmt::string_view& fmt, auto &&... args)
323+ [[noreturn]]
324+ void abort (const fmt::string_view& fmt, auto &&... args)
316325{
317326 throw std::runtime_error (
318327 fmt::format (fmt::runtime (fmt), std::forward<decltype (args)>(args)...));
319328}
320329
330+ void abortif (const bool cond, const fmt::string_view& fmt, auto &&... args)
331+ {
332+ if (cond) {
333+ throw std::runtime_error (fmt::format (
334+ fmt::runtime (fmt), std::forward<decltype (args)>(args)...));
335+ }
336+ }
337+
321338TEST_SUITE_END ();
322339};
323340
0 commit comments