diff options
author | krock21 <krock21@yandex-team.ru> | 2022-02-10 16:46:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:02 +0300 |
commit | 4aae166b5d23fd02653919f43e2015cd636fa6fd (patch) | |
tree | 70e52225c1ede3476f358bc4699197ace987d46d /library | |
parent | 9ab30620977aa96ae9e9da959e2f7e1370cb796d (diff) | |
download | ydb-4aae166b5d23fd02653919f43e2015cd636fa6fd.tar.gz |
Restoring authorship annotation for <krock21@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library')
21 files changed, 226 insertions, 226 deletions
diff --git a/library/cpp/blockcodecs/codecs_ut.cpp b/library/cpp/blockcodecs/codecs_ut.cpp index bfe5a23690..9f56d0d89f 100644 --- a/library/cpp/blockcodecs/codecs_ut.cpp +++ b/library/cpp/blockcodecs/codecs_ut.cpp @@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TBlockCodecsTest) { d.AsString(res); UNIT_ASSERT_EQUAL(NBlockCodecs::TData(res), NBlockCodecs::TData(data)); } catch (...) { - Cerr << c->Name() << "(" << res.Quote() << ")(" << TString{NBlockCodecs::TData(data)}.Quote() << ")" << Endl; + Cerr << c->Name() << "(" << res.Quote() << ")(" << TString{NBlockCodecs::TData(data)}.Quote() << ")" << Endl; throw; } diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index 6097e40131..dcd1dbf9e1 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -12,20 +12,20 @@ int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { return cp.stricmp(s1.data(), p); } -int TCiString::compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp) { - int rv = cp.strnicmp(p1.data(), p2.data(), Min(p1.size(), p2.size())); - return rv ? rv : p1.size() < p2.size() ? -1 : p1.size() == p2.size() ? 0 : 1; +int TCiString::compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp) { + int rv = cp.strnicmp(p1.data(), p2.data(), Min(p1.size(), p2.size())); + return rv ? rv : p1.size() < p2.size() ? -1 : p1.size() == p2.size() ? 0 : 1; } -bool TCiString::is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { - size_t len = what.size(); - return len <= of.size() && cp.strnicmp(what.data(), of.data(), len) == 0; +bool TCiString::is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { + size_t len = what.size(); + return len <= of.size() && cp.strnicmp(what.data(), of.data(), len) == 0; } -bool TCiString::is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { - size_t len = what.size(); - size_t slen = of.size(); - return (len <= slen) && (0 == cp.strnicmp(what.data(), of.data() + slen - len, len)); +bool TCiString::is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { + size_t len = what.size(); + size_t slen = of.size(); + return (len <= slen) && (0 == cp.strnicmp(what.data(), of.data() + slen - len, len)); } size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { diff --git a/library/cpp/charset/ci_string.h b/library/cpp/charset/ci_string.h index edf24c1b6f..2c61f5ca76 100644 --- a/library/cpp/charset/ci_string.h +++ b/library/cpp/charset/ci_string.h @@ -51,7 +51,7 @@ public: { } - explicit TCiString(const TStringBuf& s) + explicit TCiString(const TStringBuf& s) : TString(s) { } @@ -60,17 +60,17 @@ public: static int compare(const TCiString& s1, const TCiString& s2, const CodePage& cp = csYandex); static int compare(const char* p, const TCiString& s2, const CodePage& cp = csYandex); static int compare(const TCiString& s1, const char* p, const CodePage& cp = csYandex); - static int compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp = csYandex); + static int compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp = csYandex); // TODO: implement properly in TString via enum ECaseSensitivity - static bool is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp = csYandex); - static bool is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp = csYandex); + static bool is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp = csYandex); + static bool is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp = csYandex); - bool StartsWith(const TStringBuf& s, const CodePage& cp = csYandex) const { + bool StartsWith(const TStringBuf& s, const CodePage& cp = csYandex) const { return is_prefix(s, *this, cp); } - bool EndsWith(const TStringBuf& s, const CodePage& cp = csYandex) const { + bool EndsWith(const TStringBuf& s, const CodePage& cp = csYandex) const { return is_suffix(s, *this, cp); } @@ -217,8 +217,8 @@ struct ci_hash { inline size_t operator()(const char* s) const { return TCiString::hashVal(s, strlen(s)); } - inline size_t operator()(const TStringBuf& s) const { - return TCiString::hashVal(s.data(), s.size()); + inline size_t operator()(const TStringBuf& s) const { + return TCiString::hashVal(s.data(), s.size()); } }; @@ -240,8 +240,8 @@ struct TCIHash { template <> struct TCIHash<const char*> { - inline size_t operator()(const TStringBuf& s) const { - return TCiString::hashVal(s.data(), s.size()); + inline size_t operator()(const TStringBuf& s) const { + return TCiString::hashVal(s.data(), s.size()); } }; @@ -270,8 +270,8 @@ struct ci_equal_to { return csYandex.stricmp(x, y) == 0; } // this implementation is not suitable for strings with zero characters inside, sorry - bool operator()(const TStringBuf& x, const TStringBuf& y) const { - return x.size() == y.size() && csYandex.strnicmp(x.data(), y.data(), y.size()) == 0; + bool operator()(const TStringBuf& x, const TStringBuf& y) const { + return x.size() == y.size() && csYandex.strnicmp(x.data(), y.data(), y.size()) == 0; } }; diff --git a/library/cpp/deprecated/accessors/memory_traits.h b/library/cpp/deprecated/accessors/memory_traits.h index aa837705d3..ef4012f6d6 100644 --- a/library/cpp/deprecated/accessors/memory_traits.h +++ b/library/cpp/deprecated/accessors/memory_traits.h @@ -147,7 +147,7 @@ struct TMemoryTraits<TArrayRef<T>>: public TElementDependentMemoryTraits<T> { }; template <typename TCharType, typename TCharTraits> -struct TMemoryTraits<TBasicStringBuf<TCharType, TCharTraits>>: public TElementDependentMemoryTraits<TCharType> { +struct TMemoryTraits<TBasicStringBuf<TCharType, TCharTraits>>: public TElementDependentMemoryTraits<TCharType> { enum { OwnsMemory = false }; diff --git a/library/cpp/getopt/small/completer_command.cpp b/library/cpp/getopt/small/completer_command.cpp index 5e593eec7e..d502728750 100644 --- a/library/cpp/getopt/small/completer_command.cpp +++ b/library/cpp/getopt/small/completer_command.cpp @@ -104,7 +104,7 @@ namespace NLastGetopt { } else if (shell == "zsh") { TZshCompletionGenerator(opts).Generate(command, Cout); } else { - Cerr << "Unknown shell name " << TString{shell}.Quote() << Endl; + Cerr << "Unknown shell name " << TString{shell}.Quote() << Endl; exit(1); } exit(0); diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 4ec27a29e8..e23a8257fc 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -16,7 +16,7 @@ THttpInputHeader::THttpInputHeader(const TStringBuf header) { size_t pos = header.find(':'); if (pos == TString::npos) { - ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")"; + ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")"; } Name_ = TString(header.cbegin(), header.cbegin() + pos); diff --git a/library/cpp/http/io/headers_ut.cpp b/library/cpp/http/io/headers_ut.cpp index 1d23ef8fdc..b068de8fe4 100644 --- a/library/cpp/http/io/headers_ut.cpp +++ b/library/cpp/http/io/headers_ut.cpp @@ -20,7 +20,7 @@ namespace { } public: - void Add(TStringBuf name, TStringBuf value) { + void Add(TStringBuf name, TStringBuf value) { Impl.emplace(TString(name), TString(value)); } @@ -53,7 +53,7 @@ class THttpHeadersTest: public TTestBase { UNIT_TEST_SUITE_END(); private: - typedef void (*TAddHeaderFunction)(THttpHeaders&, TStringBuf name, TStringBuf value); + typedef void (*TAddHeaderFunction)(THttpHeaders&, TStringBuf name, TStringBuf value); typedef void (*TAddOrReplaceHeaderFunction)(THttpHeaders&, TStringBuf name, TStringBuf value); public: @@ -65,11 +65,11 @@ public: void TestFindHeader(); private: - static void AddHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) { + static void AddHeaderImpl1Arg(THttpHeaders& headers, TStringBuf name, TStringBuf value) { headers.AddHeader(THttpInputHeader(TString(name), TString(value))); } - static void AddHeaderImpl2Args(THttpHeaders& headers, TStringBuf name, TStringBuf value) { + static void AddHeaderImpl2Args(THttpHeaders& headers, TStringBuf name, TStringBuf value) { headers.AddHeader(TString(name), TString(value)); } @@ -156,7 +156,7 @@ void THttpHeadersTest::TestAddHeaderTemplateness() { h1.AddHeader("h1", "v1"); h1.AddHeader("h2", TString("v2")); h1.AddHeader("h3", TStringBuf("v3")); - h1.AddHeader("h4", TStringBuf("v4")); + h1.AddHeader("h4", TStringBuf("v4")); THeadersExistence h2; h2.Add("h1", "v1"); diff --git a/library/cpp/json/easy_parse/json_easy_parser.cpp b/library/cpp/json/easy_parse/json_easy_parser.cpp index 3c781f544b..f88894e8ff 100644 --- a/library/cpp/json/easy_parse/json_easy_parser.cpp +++ b/library/cpp/json/easy_parse/json_easy_parser.cpp @@ -160,7 +160,7 @@ namespace NJson { Pop(); UpdateRule(); } - Stack.push_back(TPathElem(TString{key})); + Stack.push_back(TPathElem(TString{key})); if (CurrentFieldIdx >= 0) HasFormatError = true; else diff --git a/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp b/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp index 2d11b9d5ba..8b0ac1f4ca 100644 --- a/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp +++ b/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp @@ -93,8 +93,8 @@ namespace NMonitoring { NProto::TLabel* label = (Sample_ == nullptr) ? Samples_->AddCommonLabels() : Sample_->AddLabels(); - label->SetName(TString{name}); - label->SetValue(TString{value}); + label->SetName(TString{name}); + label->SetValue(TString{value}); } void OnDouble(TInstant time, double value) override { @@ -181,8 +181,8 @@ namespace NMonitoring { ? Samples_->AddCommonLabels() : Sample_->AddLabels(); - label->SetName(TString{name}); - label->SetValue(TString{value}); + label->SetName(TString{name}); + label->SetValue(TString{value}); } void OnDouble(TInstant time, double value) override { diff --git a/library/cpp/regex/pire/regexp.h b/library/cpp/regex/pire/regexp.h index 94bba4064b..58e782f721 100644 --- a/library/cpp/regex/pire/regexp.h +++ b/library/cpp/regex/pire/regexp.h @@ -47,17 +47,17 @@ namespace NRegExp { bool AndNotSupport = false; }; - static inline NPire::TFsm Parse(const TStringBuf& regexp, + static inline NPire::TFsm Parse(const TStringBuf& regexp, const TOptions& opts, const bool needDetermine = true) { NPire::TLexer lexer; if (opts.Charset == CODES_UNKNOWN) { - lexer.Assign(regexp.data(), regexp.data() + regexp.size()); + lexer.Assign(regexp.data(), regexp.data() + regexp.size()); } else { - TVector<wchar32> ucs4(regexp.size() + 1); + TVector<wchar32> ucs4(regexp.size() + 1); size_t inRead = 0; size_t outWritten = 0; - int recodeRes = RecodeToUnicode(opts.Charset, regexp.data(), ucs4.data(), - regexp.size(), regexp.size(), inRead, outWritten); + int recodeRes = RecodeToUnicode(opts.Charset, regexp.data(), ucs4.data(), + regexp.size(), regexp.size(), inRead, outWritten); Y_ASSERT(recodeRes == RECODE_OK); Y_ASSERT(outWritten < ucs4.size()); ucs4[outWritten] = 0; @@ -112,7 +112,7 @@ namespace NRegExp { typedef TScannerType TScanner; public: - inline explicit TFsmParser(const TStringBuf& regexp, + inline explicit TFsmParser(const TStringBuf& regexp, const TOptions& opts = TOptions(), bool needDetermine = true) : Scanner(Parse(regexp, opts, needDetermine).template Compile<TScanner>()) { @@ -139,7 +139,7 @@ namespace NRegExp { class TFsm: public TFsmParser<NPire::TNonrelocScanner> { public: - inline explicit TFsm(const TStringBuf& regexp, + inline explicit TFsm(const TStringBuf& regexp, const TOptions& opts = TOptions()) : TFsmParser<TScanner>(regexp, opts) { @@ -165,7 +165,7 @@ namespace NRegExp { } struct TCapturingFsm : TFsmParser<NPire::TCapturingScanner> { - inline explicit TCapturingFsm(const TStringBuf& regexp, + inline explicit TCapturingFsm(const TStringBuf& regexp, TOptions opts = TOptions()) : TFsmParser<TScanner>(regexp, opts.SetSurround(true).CapturePos ? opts : opts.SetCapture(1)) { @@ -178,7 +178,7 @@ namespace NRegExp { }; struct TSlowCapturingFsm : TFsmParser<NPire::TSlowCapturingScanner> { - inline explicit TSlowCapturingFsm(const TStringBuf& regexp, + inline explicit TSlowCapturingFsm(const TStringBuf& regexp, TOptions opts = TOptions()) : TFsmParser<TScanner>(regexp, opts.SetSurround(true).CapturePos ? opts : opts.SetCapture(1), false) { @@ -241,8 +241,8 @@ namespace NRegExp { return *this; } - inline TMatcher& Match(const TStringBuf& s, bool addBegin = false, bool addEnd = false) noexcept { - return Match(s.data(), s.size(), addBegin, addEnd); + inline TMatcher& Match(const TStringBuf& s, bool addBegin = false, bool addEnd = false) noexcept { + return Match(s.data(), s.size(), addBegin, addEnd); } inline const char* Find(const char* b, const char* e) noexcept { @@ -273,8 +273,8 @@ namespace NRegExp { return *this; } - inline TSearcher& Search(const TStringBuf& s) noexcept { - return Search(s.data(), s.size()); + inline TSearcher& Search(const TStringBuf& s) noexcept { + return Search(s.data(), s.size()); } inline TStringBuf GetCaptured() const noexcept { @@ -306,8 +306,8 @@ namespace NRegExp { return GetAns(); } - inline TSlowSearcher& Search(const TStringBuf& s) noexcept { - return Search(s.data(), s.size()); + inline TSlowSearcher& Search(const TStringBuf& s) noexcept { + return Search(s.data(), s.size()); } inline TStringBuf GetCaptured() const noexcept { diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index 66001c4769..bdf770abe0 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -31,14 +31,14 @@ namespace { Y_VERIFY(false, "Redefinition of key %s:\n" " old value: %s,\n" " new value: %s.", - TString{key}.Quote().c_str(), + TString{key}.Quote().c_str(), Decompress(value).Quote().c_str(), Decompress(data).Quote().c_str()); } else { Y_VERIFY(false, "Redefinition of key %s," " old size: %zu," " new size: %zu.", - TString{key}.Quote().c_str(), vsize, dsize); + TString{key}.Quote().c_str(), vsize, dsize); } } } else { diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h index f778a6425a..70917c89d1 100644 --- a/library/cpp/string_utils/base64/base64.h +++ b/library/cpp/string_utils/base64/base64.h @@ -2,7 +2,7 @@ #include <util/system/defaults.h> #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> /* @return Size of the buffer required to decode Base64 encoded data of size `len`. */ diff --git a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp index 768555ea3a..9c8bbbdfdd 100644 --- a/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp +++ b/library/cpp/string_utils/relaxed_escaper/relaxed_escaper_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -#define RESC_FIXED_STR(s) TStringBuf(s, sizeof(s) - 1) -static const TStringBuf CommonTestData[] = { +#define RESC_FIXED_STR(s) TStringBuf(s, sizeof(s) - 1) +static const TStringBuf CommonTestData[] = { // Should be valid UTF-8. RESC_FIXED_STR("http://ya.ru/"), RESC_FIXED_STR("http://ya.ru/"), RESC_FIXED_STR("http://ya.ru/\\x17\\n"), RESC_FIXED_STR("http://ya.ru/\x17\n"), @@ -29,8 +29,8 @@ Y_UNIT_TEST_SUITE(TRelaxedEscaperTest) { Y_UNIT_TEST(TestEscaper) { using namespace NEscJ; for (size_t i = 0; i < Y_ARRAY_SIZE(CommonTestData); i += 2) { - TString expected(CommonTestData[i].data(), CommonTestData[i].size()); - TString source(CommonTestData[i + 1].data(), CommonTestData[i + 1].size()); + TString expected(CommonTestData[i].data(), CommonTestData[i].size()); + TString source(CommonTestData[i + 1].data(), CommonTestData[i + 1].size()); TString actual(EscapeJ<false>(source)); TString actual2(UnescapeC(expected)); diff --git a/library/cpp/string_utils/ztstrbuf/ztstrbuf.h b/library/cpp/string_utils/ztstrbuf/ztstrbuf.h index 5fab768d8c..eb88d28b3e 100644 --- a/library/cpp/string_utils/ztstrbuf/ztstrbuf.h +++ b/library/cpp/string_utils/ztstrbuf/ztstrbuf.h @@ -1,7 +1,7 @@ #pragma once #include <util/generic/strbuf.h> -#include <util/generic/string.h> +#include <util/generic/string.h> /* * Zero-terminated string view. diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp index fa3a47fe16..9661846e82 100644 --- a/library/cpp/testing/common/env.cpp +++ b/library/cpp/testing/common/env.cpp @@ -5,15 +5,15 @@ #include <util/folder/dirut.h> #include <util/folder/path.h> #include <util/generic/singleton.h> -#include <util/stream/file.h> +#include <util/stream/file.h> #include <util/stream/fwd.h> #include <util/system/env.h> #include <util/system/file.h> #include <util/system/file_lock.h> #include <util/system/guard.h> -#include <library/cpp/json/json_reader.h> -#include <library/cpp/json/json_value.h> +#include <library/cpp/json/json_reader.h> +#include <library/cpp/json/json_value.h> #include <library/cpp/json/json_writer.h> TString ArcadiaSourceRoot() { @@ -41,12 +41,12 @@ TString BinaryPath(TStringBuf path) { } TString GetArcadiaTestsData() { - TString atdRoot = NPrivate::GetTestEnv().ArcadiaTestsDataDir; - if (atdRoot) { - return atdRoot; + TString atdRoot = NPrivate::GetTestEnv().ArcadiaTestsDataDir; + if (atdRoot) { + return atdRoot; } - TString path = NPrivate::GetCwd(); + TString path = NPrivate::GetCwd(); const char pathsep = GetDirectorySeparator(); while (!path.empty()) { TString dataDir = path + "/arcadia_tests_data"; @@ -65,12 +65,12 @@ TString GetArcadiaTestsData() { } TString GetWorkPath() { - TString workPath = NPrivate::GetTestEnv().WorkPath; - if (workPath) { - return workPath; + TString workPath = NPrivate::GetTestEnv().WorkPath; + if (workPath) { + return workPath; } - - return NPrivate::GetCwd(); + + return NPrivate::GetCwd(); } TFsPath GetOutputPath() { @@ -78,7 +78,7 @@ TFsPath GetOutputPath() { } const TString& GetRamDrivePath() { - return NPrivate::GetTestEnv().RamDrivePath; + return NPrivate::GetTestEnv().RamDrivePath; } const TString& GetYtHddPath() { @@ -86,7 +86,7 @@ const TString& GetYtHddPath() { } const TString& GetOutputRamDrivePath() { - return NPrivate::GetTestEnv().TestOutputRamDrivePath; + return NPrivate::GetTestEnv().TestOutputRamDrivePath; } const TString& GdbPath() { @@ -144,68 +144,68 @@ void StopProcessCoreWatching(int pid) { } bool FromYaTest() { - return NPrivate::GetTestEnv().IsRunningFromTest; + return NPrivate::GetTestEnv().IsRunningFromTest; } - -namespace NPrivate { - TTestEnv::TTestEnv() { - ReInitialize(); - } - - void TTestEnv::ReInitialize() { - IsRunningFromTest = false; - ArcadiaTestsDataDir = ""; - SourceRoot = ""; - BuildRoot = ""; - WorkPath = ""; - RamDrivePath = ""; + +namespace NPrivate { + TTestEnv::TTestEnv() { + ReInitialize(); + } + + void TTestEnv::ReInitialize() { + IsRunningFromTest = false; + ArcadiaTestsDataDir = ""; + SourceRoot = ""; + BuildRoot = ""; + WorkPath = ""; + RamDrivePath = ""; YtHddPath = ""; - TestOutputRamDrivePath = ""; + TestOutputRamDrivePath = ""; GdbPath = ""; CoreSearchFile = ""; TestParameters.clear(); - - const TString contextFilename = GetEnv("YA_TEST_CONTEXT_FILE"); - if (contextFilename) { - NJson::TJsonValue context; - NJson::ReadJsonTree(TFileInput(contextFilename).ReadAll(), &context); - - NJson::TJsonValue* value; - - value = context.GetValueByPath("runtime.source_root"); - if (value) { - SourceRoot = value->GetStringSafe(""); - } - - value = context.GetValueByPath("runtime.build_root"); - if (value) { - BuildRoot = value->GetStringSafe(""); - } - - value = context.GetValueByPath("runtime.atd_root"); - if (value) { - ArcadiaTestsDataDir = value->GetStringSafe(""); - } - - value = context.GetValueByPath("runtime.work_path"); - if (value) { - WorkPath = value->GetStringSafe(""); - } - - value = context.GetValueByPath("runtime.ram_drive_path"); - if (value) { - RamDrivePath = value->GetStringSafe(""); - } - + + const TString contextFilename = GetEnv("YA_TEST_CONTEXT_FILE"); + if (contextFilename) { + NJson::TJsonValue context; + NJson::ReadJsonTree(TFileInput(contextFilename).ReadAll(), &context); + + NJson::TJsonValue* value; + + value = context.GetValueByPath("runtime.source_root"); + if (value) { + SourceRoot = value->GetStringSafe(""); + } + + value = context.GetValueByPath("runtime.build_root"); + if (value) { + BuildRoot = value->GetStringSafe(""); + } + + value = context.GetValueByPath("runtime.atd_root"); + if (value) { + ArcadiaTestsDataDir = value->GetStringSafe(""); + } + + value = context.GetValueByPath("runtime.work_path"); + if (value) { + WorkPath = value->GetStringSafe(""); + } + + value = context.GetValueByPath("runtime.ram_drive_path"); + if (value) { + RamDrivePath = value->GetStringSafe(""); + } + value = context.GetValueByPath("runtime.yt_hdd_path"); if (value) { YtHddPath = value->GetStringSafe(""); } - value = context.GetValueByPath("runtime.test_output_ram_drive_path"); - if (value) { - TestOutputRamDrivePath = value->GetStringSafe(""); - } + value = context.GetValueByPath("runtime.test_output_ram_drive_path"); + if (value) { + TestOutputRamDrivePath = value->GetStringSafe(""); + } value = context.GetValueByPath("runtime.gdb_bin"); if (value) { @@ -223,53 +223,53 @@ namespace NPrivate { if (value) { CoreSearchFile = value->GetStringSafe(""); } - } - + } + if (!YtHddPath) { YtHddPath = GetEnv("HDD_PATH"); } - if (!SourceRoot) { - SourceRoot = GetEnv("ARCADIA_SOURCE_ROOT"); - } - - if (!BuildRoot) { - BuildRoot = GetEnv("ARCADIA_BUILD_ROOT"); - } - - if (!ArcadiaTestsDataDir) { - ArcadiaTestsDataDir = GetEnv("ARCADIA_TESTS_DATA_DIR"); - } - - if (!WorkPath) { - WorkPath = GetEnv("TEST_WORK_PATH"); - } - - if (!RamDrivePath) { - RamDrivePath = GetEnv("YA_TEST_RAM_DRIVE_PATH"); - } - - if (!TestOutputRamDrivePath) { - TestOutputRamDrivePath = GetEnv("YA_TEST_OUTPUT_RAM_DRIVE_PATH"); - } - - const TString fromEnv = GetEnv("YA_TEST_RUNNER"); - IsRunningFromTest = (fromEnv == "1"); - } - + if (!SourceRoot) { + SourceRoot = GetEnv("ARCADIA_SOURCE_ROOT"); + } + + if (!BuildRoot) { + BuildRoot = GetEnv("ARCADIA_BUILD_ROOT"); + } + + if (!ArcadiaTestsDataDir) { + ArcadiaTestsDataDir = GetEnv("ARCADIA_TESTS_DATA_DIR"); + } + + if (!WorkPath) { + WorkPath = GetEnv("TEST_WORK_PATH"); + } + + if (!RamDrivePath) { + RamDrivePath = GetEnv("YA_TEST_RAM_DRIVE_PATH"); + } + + if (!TestOutputRamDrivePath) { + TestOutputRamDrivePath = GetEnv("YA_TEST_OUTPUT_RAM_DRIVE_PATH"); + } + + const TString fromEnv = GetEnv("YA_TEST_RUNNER"); + IsRunningFromTest = (fromEnv == "1"); + } + void TTestEnv::AddTestParam(TStringBuf name, TStringBuf value) { TestParameters[TString{name}] = value; } - TString GetCwd() { - try { - return NFs::CurrentWorkingDirectory(); - } catch (...) { - return {}; - } - } - - const TTestEnv& GetTestEnv() { - return *Singleton<TTestEnv>(); - } -} + TString GetCwd() { + try { + return NFs::CurrentWorkingDirectory(); + } catch (...) { + return {}; + } + } + + const TTestEnv& GetTestEnv() { + return *Singleton<TTestEnv>(); + } +} diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h index 7b89aa1bed..aa247afb9a 100644 --- a/library/cpp/testing/common/env.h +++ b/library/cpp/testing/common/env.h @@ -55,30 +55,30 @@ void WatchProcessCore(int pid, const TFsPath& binaryPath, const TFsPath& cwd = T void StopProcessCoreWatching(int pid); #define SRC_(path) ArcadiaFromCurrentLocation(__SOURCE_FILE__, path) - -namespace NPrivate { - class TTestEnv { - public: - TTestEnv(); - - void ReInitialize(); - + +namespace NPrivate { + class TTestEnv { + public: + TTestEnv(); + + void ReInitialize(); + void AddTestParam(TStringBuf name, TStringBuf value); - bool IsRunningFromTest; - TString ArcadiaTestsDataDir; - TString SourceRoot; - TString BuildRoot; - TString WorkPath; - TString RamDrivePath; + bool IsRunningFromTest; + TString ArcadiaTestsDataDir; + TString SourceRoot; + TString BuildRoot; + TString WorkPath; + TString RamDrivePath; TString YtHddPath; - TString TestOutputRamDrivePath; + TString TestOutputRamDrivePath; TString GdbPath; TString CoreSearchFile; std::unordered_map<TString, TString> TestParameters; - }; - - TString GetCwd(); - - const TTestEnv& GetTestEnv(); -} + }; + + TString GetCwd(); + + const TTestEnv& GetTestEnv(); +} diff --git a/library/cpp/testing/common/ut/env_ut.cpp b/library/cpp/testing/common/ut/env_ut.cpp index 2aed1e4a25..64a79bb411 100644 --- a/library/cpp/testing/common/ut/env_ut.cpp +++ b/library/cpp/testing/common/ut/env_ut.cpp @@ -10,52 +10,52 @@ TEST(Runtime, ArcadiaSourceRoot) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename { auto tmpDir = ::GetSystemTempDir(); NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", tmpDir); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(tmpDir, ArcadiaSourceRoot()); } { NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", ""); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_FALSE(ArcadiaSourceRoot().empty()); } } TEST(Runtime, BuildRoot) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename { auto tmpDir = ::GetSystemTempDir(); NTesting::TScopedEnvironment guard("ARCADIA_BUILD_ROOT", tmpDir); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(tmpDir, BuildRoot()); } { NTesting::TScopedEnvironment guard("ARCADIA_BUILD_ROOT", ""); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_FALSE(BuildRoot().empty()); } } TEST(Runtime, BinaryPath) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_TRUE(TFsPath(BinaryPath("library/cpp/testing/common/ut")).Exists()); } TEST(Runtime, GetArcadiaTestsData) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename { auto tmpDir = ::GetSystemTempDir(); NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", tmpDir); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(tmpDir, GetArcadiaTestsData()); } { NTesting::TScopedEnvironment guard("ARCADIA_TESTS_DATA_DIR", ""); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); auto path = GetArcadiaTestsData(); // it is not error if path is empty const bool ok = (path.empty() || GetBaseName(path) == "arcadia_tests_data"); @@ -64,39 +64,39 @@ TEST(Runtime, GetArcadiaTestsData) { } TEST(Runtime, GetWorkPath) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename { auto tmpDir = ::GetSystemTempDir(); NTesting::TScopedEnvironment guard("TEST_WORK_PATH", tmpDir); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(tmpDir, GetWorkPath()); } { NTesting::TScopedEnvironment guard("TEST_WORK_PATH", ""); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_TRUE(!GetWorkPath().empty()); } } TEST(Runtime, GetOutputPath) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(GetOutputPath().Basename(), "testing_out_stuff"); } TEST(Runtime, GetRamDrivePath) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename auto tmpDir = ::GetSystemTempDir(); NTesting::TScopedEnvironment guard("YA_TEST_RAM_DRIVE_PATH", tmpDir); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(tmpDir, GetRamDrivePath()); } TEST(Runtime, GetOutputRamDrivePath) { - NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename + NTesting::TScopedEnvironment contextGuard("YA_TEST_CONTEXT_FILE", ""); // remove context filename auto tmpDir = ::GetSystemTempDir(); NTesting::TScopedEnvironment guard("YA_TEST_OUTPUT_RAM_DRIVE_PATH", tmpDir); - Singleton<NPrivate::TTestEnv>()->ReInitialize(); + Singleton<NPrivate::TTestEnv>()->ReInitialize(); EXPECT_EQ(tmpDir, GetOutputRamDrivePath()); } diff --git a/library/cpp/testing/common/ya.make b/library/cpp/testing/common/ya.make index 2f4b0ce26e..ac83cc98ce 100644 --- a/library/cpp/testing/common/ya.make +++ b/library/cpp/testing/common/ya.make @@ -14,10 +14,10 @@ SRCS( scope.cpp ) -PEERDIR( - library/cpp/json -) - +PEERDIR( + library/cpp/json +) + END() RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp index c5712ae9d2..c3b4b3bf34 100644 --- a/library/cpp/testing/unittest/checks.cpp +++ b/library/cpp/testing/unittest/checks.cpp @@ -1,4 +1,4 @@ -#include <util/generic/string.h> +#include <util/generic/string.h> #include <util/string/type.h> bool CheckExceptionMessage(const char* msg, TString& err) { diff --git a/library/cpp/xml/document/node-attr.h b/library/cpp/xml/document/node-attr.h index 6e74403943..2dce81b158 100644 --- a/library/cpp/xml/document/node-attr.h +++ b/library/cpp/xml/document/node-attr.h @@ -22,7 +22,7 @@ namespace NXml { try { res = FromString<T>(CAST2CHAR(value.Get())); } catch (TFromStringException&) { - THROW(XmlException, "Failed to convert string " << TString{TStringBuf(CAST2CHAR(value.Get())).substr(0, 50)}.Quote() << " from '" << errContext << "' to requested type"); + THROW(XmlException, "Failed to convert string " << TString{TStringBuf(CAST2CHAR(value.Get())).substr(0, 50)}.Quote() << " from '" << errContext << "' to requested type"); } } diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py index e36f47a78f..8292d750a8 100644 --- a/library/python/pytest/plugins/collection.py +++ b/library/python/pytest/plugins/collection.py @@ -1,6 +1,6 @@ import os import sys -from six import reraise +from six import reraise import py @@ -61,19 +61,19 @@ class DoctestModule(LoadedModule): optionflags = _pytest.doctest.get_optionflags(self) runner = doctest.DebugRunner(verbose=0, optionflags=optionflags) - try: + try: for test in finder.find(module, self.name[:-len('.py')]): - if test.examples: # skip empty doctests + if test.examples: # skip empty doctests yield getattr(_pytest.doctest.DoctestItem, 'from_parent', _pytest.doctest.DoctestItem)( name=test.name, parent=self, runner=runner, dtest=test) except Exception: - import logging - logging.exception('DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make') - etype, exc, tb = sys.exc_info() - msg = 'DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make' + import logging + logging.exception('DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make') + etype, exc, tb = sys.exc_info() + msg = 'DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make' reraise(etype, type(exc)('{}\n{}'.format(exc, msg)), tb) @@ -116,13 +116,13 @@ class CollectionPlugin(object): if not pytest_ignore_collect(module, session, filenames_filter, accept_filename_predicate): yield module - if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no': + if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no': module = DoctestModule.from_parent(name=test_module, parent=session) - if not pytest_ignore_collect(module, session, filenames_filter, accept_filename_predicate): - yield module + if not pytest_ignore_collect(module, session, filenames_filter, accept_filename_predicate): + yield module - if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no': - for doctest_module in self._doctest_modules: + if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no': + for doctest_module in self._doctest_modules: yield DoctestModule.from_parent(name=doctest_module, parent=session, namespace=False) session.collect = collect |