mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace Test {
|
||||
|
||||
Crash::Crash(String test_type, Function<Crash::Failure()> crash_function, int crash_signal)
|
||||
Crash::Crash(DeprecatedString test_type, Function<Crash::Failure()> crash_function, int crash_signal)
|
||||
: m_type(move(test_type))
|
||||
, m_crash_function(move(crash_function))
|
||||
, m_crash_signal(crash_signal)
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
|
||||
namespace Test {
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
static constexpr int ANY_SIGNAL = -1;
|
||||
|
||||
Crash(String test_type, Function<Crash::Failure()> crash_function, int crash_signal = ANY_SIGNAL);
|
||||
Crash(DeprecatedString test_type, Function<Crash::Failure()> crash_function, int crash_signal = ANY_SIGNAL);
|
||||
|
||||
bool run(RunType run_type = RunType::UsingChildProcess);
|
||||
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
using Report = Variant<Failure, int>;
|
||||
bool do_report(Report report);
|
||||
|
||||
String m_type;
|
||||
DeprecatedString m_type;
|
||||
Function<Crash::Failure()> m_crash_function;
|
||||
int m_crash_signal;
|
||||
};
|
||||
|
|
|
@ -88,16 +88,16 @@
|
|||
} __testjs_flag_hook_##flag;
|
||||
|
||||
#define TEST_ROOT(path) \
|
||||
String Test::JS::g_test_root_fragment = path
|
||||
DeprecatedString Test::JS::g_test_root_fragment = path
|
||||
|
||||
#define TESTJS_RUN_FILE_FUNCTION(...) \
|
||||
struct __TestJS_run_file { \
|
||||
__TestJS_run_file() \
|
||||
{ \
|
||||
::Test::JS::g_run_file = hook; \
|
||||
} \
|
||||
static ::Test::JS::IntermediateRunFileResult hook(String const&, JS::Interpreter&, JS::ExecutionContext&); \
|
||||
} __testjs_common_run_file {}; \
|
||||
#define TESTJS_RUN_FILE_FUNCTION(...) \
|
||||
struct __TestJS_run_file { \
|
||||
__TestJS_run_file() \
|
||||
{ \
|
||||
::Test::JS::g_run_file = hook; \
|
||||
} \
|
||||
static ::Test::JS::IntermediateRunFileResult hook(DeprecatedString const&, JS::Interpreter&, JS::ExecutionContext&); \
|
||||
} __testjs_common_run_file {}; \
|
||||
::Test::JS::IntermediateRunFileResult __TestJS_run_file::hook(__VA_ARGS__)
|
||||
|
||||
#define TESTJS_CREATE_INTERPRETER_HOOK(...) \
|
||||
|
@ -128,34 +128,34 @@ static constexpr auto TOP_LEVEL_TEST_NAME = "__$$TOP_LEVEL$$__";
|
|||
extern RefPtr<JS::VM> g_vm;
|
||||
extern bool g_collect_on_every_allocation;
|
||||
extern bool g_run_bytecode;
|
||||
extern String g_currently_running_test;
|
||||
extern DeprecatedString g_currently_running_test;
|
||||
struct FunctionWithLength {
|
||||
JS::ThrowCompletionOr<JS::Value> (*function)(JS::VM&);
|
||||
size_t length { 0 };
|
||||
};
|
||||
extern HashMap<String, FunctionWithLength> s_exposed_global_functions;
|
||||
extern String g_test_root_fragment;
|
||||
extern String g_test_root;
|
||||
extern HashMap<DeprecatedString, FunctionWithLength> s_exposed_global_functions;
|
||||
extern DeprecatedString g_test_root_fragment;
|
||||
extern DeprecatedString g_test_root;
|
||||
extern int g_test_argc;
|
||||
extern char** g_test_argv;
|
||||
extern Function<void()> g_main_hook;
|
||||
extern Function<NonnullOwnPtr<JS::Interpreter>()> g_create_interpreter_hook;
|
||||
extern HashMap<bool*, Tuple<String, String, char>> g_extra_args;
|
||||
extern HashMap<bool*, Tuple<DeprecatedString, DeprecatedString, char>> g_extra_args;
|
||||
|
||||
struct ParserError {
|
||||
JS::ParserError error;
|
||||
String hint;
|
||||
DeprecatedString hint;
|
||||
};
|
||||
|
||||
struct JSFileResult {
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
Optional<ParserError> error {};
|
||||
double time_taken { 0 };
|
||||
// A failed test takes precedence over a skipped test, which both have
|
||||
// precedence over a passed test
|
||||
Test::Result most_severe_test_result { Test::Result::Pass };
|
||||
Vector<Test::Suite> suites {};
|
||||
Vector<String> logged_messages {};
|
||||
Vector<DeprecatedString> logged_messages {};
|
||||
};
|
||||
|
||||
enum class RunFileHookResult {
|
||||
|
@ -164,11 +164,11 @@ enum class RunFileHookResult {
|
|||
};
|
||||
|
||||
using IntermediateRunFileResult = AK::Result<JSFileResult, RunFileHookResult>;
|
||||
extern IntermediateRunFileResult (*g_run_file)(String const&, JS::Interpreter&, JS::ExecutionContext&);
|
||||
extern IntermediateRunFileResult (*g_run_file)(DeprecatedString const&, JS::Interpreter&, JS::ExecutionContext&);
|
||||
|
||||
class TestRunner : public ::Test::TestRunner {
|
||||
public:
|
||||
TestRunner(String test_root, String common_path, bool print_times, bool print_progress, bool print_json, bool detailed_json)
|
||||
TestRunner(DeprecatedString test_root, DeprecatedString common_path, bool print_times, bool print_progress, bool print_json, bool detailed_json)
|
||||
: ::Test::TestRunner(move(test_root), print_times, print_progress, print_json, detailed_json)
|
||||
, m_common_path(move(common_path))
|
||||
{
|
||||
|
@ -178,12 +178,12 @@ public:
|
|||
virtual ~TestRunner() = default;
|
||||
|
||||
protected:
|
||||
virtual void do_run_single_test(String const& test_path, size_t, size_t) override;
|
||||
virtual Vector<String> get_test_paths() const override;
|
||||
virtual JSFileResult run_file_test(String const& test_path);
|
||||
virtual void do_run_single_test(DeprecatedString const& test_path, size_t, size_t) override;
|
||||
virtual Vector<DeprecatedString> get_test_paths() const override;
|
||||
virtual JSFileResult run_file_test(DeprecatedString const& test_path);
|
||||
void print_file_result(JSFileResult const& file_result) const;
|
||||
|
||||
String m_common_path;
|
||||
DeprecatedString m_common_path;
|
||||
};
|
||||
|
||||
class TestRunnerGlobalObject final : public JS::GlobalObject {
|
||||
|
@ -265,7 +265,7 @@ inline ErrorOr<JsonValue> get_test_results(JS::Interpreter& interpreter)
|
|||
return JsonValue::from_string(json_string);
|
||||
}
|
||||
|
||||
inline void TestRunner::do_run_single_test(String const& test_path, size_t, size_t)
|
||||
inline void TestRunner::do_run_single_test(DeprecatedString const& test_path, size_t, size_t)
|
||||
{
|
||||
auto file_result = run_file_test(test_path);
|
||||
if (!m_print_json)
|
||||
|
@ -275,10 +275,10 @@ inline void TestRunner::do_run_single_test(String const& test_path, size_t, size
|
|||
ensure_suites().extend(file_result.suites);
|
||||
}
|
||||
|
||||
inline Vector<String> TestRunner::get_test_paths() const
|
||||
inline Vector<DeprecatedString> TestRunner::get_test_paths() const
|
||||
{
|
||||
Vector<String> paths;
|
||||
iterate_directory_recursively(m_test_root, [&](String const& file_path) {
|
||||
Vector<DeprecatedString> paths;
|
||||
iterate_directory_recursively(m_test_root, [&](DeprecatedString const& file_path) {
|
||||
if (!file_path.ends_with(".js"sv))
|
||||
return;
|
||||
if (!file_path.ends_with("test-common.js"sv))
|
||||
|
@ -288,7 +288,7 @@ inline Vector<String> TestRunner::get_test_paths() const
|
|||
return paths;
|
||||
}
|
||||
|
||||
inline JSFileResult TestRunner::run_file_test(String const& test_path)
|
||||
inline JSFileResult TestRunner::run_file_test(DeprecatedString const& test_path)
|
||||
{
|
||||
g_currently_running_test = test_path;
|
||||
|
||||
|
@ -411,12 +411,12 @@ inline JSFileResult TestRunner::run_file_test(String const& test_path)
|
|||
file_result.logged_messages.append(message.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
test_json.value().as_object().for_each_member([&](String const& suite_name, JsonValue const& suite_value) {
|
||||
test_json.value().as_object().for_each_member([&](DeprecatedString const& suite_name, JsonValue const& suite_value) {
|
||||
Test::Suite suite { test_path, suite_name };
|
||||
|
||||
VERIFY(suite_value.is_object());
|
||||
|
||||
suite_value.as_object().for_each_member([&](const String& test_name, const JsonValue& test_value) {
|
||||
suite_value.as_object().for_each_member([&](const DeprecatedString& test_name, const JsonValue& test_value) {
|
||||
Test::Case test { test_name, Test::Result::Fail, "", 0 };
|
||||
|
||||
VERIFY(test_value.is_object());
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace JS {
|
|||
RefPtr<::JS::VM> g_vm;
|
||||
bool g_collect_on_every_allocation = false;
|
||||
bool g_run_bytecode = false;
|
||||
String g_currently_running_test;
|
||||
HashMap<String, FunctionWithLength> s_exposed_global_functions;
|
||||
DeprecatedString g_currently_running_test;
|
||||
HashMap<DeprecatedString, FunctionWithLength> s_exposed_global_functions;
|
||||
Function<void()> g_main_hook;
|
||||
Function<NonnullOwnPtr<JS::Interpreter>()> g_create_interpreter_hook;
|
||||
HashMap<bool*, Tuple<String, String, char>> g_extra_args;
|
||||
IntermediateRunFileResult (*g_run_file)(String const&, JS::Interpreter&, JS::ExecutionContext&) = nullptr;
|
||||
String g_test_root;
|
||||
HashMap<bool*, Tuple<DeprecatedString, DeprecatedString, char>> g_extra_args;
|
||||
IntermediateRunFileResult (*g_run_file)(DeprecatedString const&, JS::Interpreter&, JS::ExecutionContext&) = nullptr;
|
||||
DeprecatedString g_test_root;
|
||||
int g_test_argc;
|
||||
char** g_test_argv;
|
||||
|
||||
|
@ -89,8 +89,8 @@ int main(int argc, char** argv)
|
|||
bool print_json = false;
|
||||
bool per_file = false;
|
||||
char const* specified_test_root = nullptr;
|
||||
String common_path;
|
||||
String test_glob;
|
||||
DeprecatedString common_path;
|
||||
DeprecatedString test_glob;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(print_times, "Show duration of each test", "show-time", 't');
|
||||
|
@ -124,7 +124,7 @@ int main(int argc, char** argv)
|
|||
if (per_file)
|
||||
print_json = true;
|
||||
|
||||
test_glob = String::formatted("*{}*", test_glob);
|
||||
test_glob = DeprecatedString::formatted("*{}*", test_glob);
|
||||
|
||||
if (getenv("DISABLE_DBG_OUTPUT")) {
|
||||
AK::set_debug_enabled(false);
|
||||
|
@ -135,21 +135,21 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
String test_root;
|
||||
DeprecatedString test_root;
|
||||
|
||||
if (specified_test_root) {
|
||||
test_root = String { specified_test_root };
|
||||
test_root = DeprecatedString { specified_test_root };
|
||||
} else {
|
||||
#ifdef AK_OS_SERENITY
|
||||
test_root = LexicalPath::join("/home/anon/Tests"sv, String::formatted("{}-tests", program_name.split_view('-').last())).string();
|
||||
test_root = LexicalPath::join("/home/anon/Tests"sv, DeprecatedString::formatted("{}-tests", program_name.split_view('-').last())).string();
|
||||
#else
|
||||
char* serenity_source_dir = getenv("SERENITY_SOURCE_DIR");
|
||||
if (!serenity_source_dir) {
|
||||
warnln("No test root given, {} requires the SERENITY_SOURCE_DIR environment variable to be set", g_program_name);
|
||||
return 1;
|
||||
}
|
||||
test_root = String::formatted("{}/{}", serenity_source_dir, g_test_root_fragment);
|
||||
common_path = String::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", serenity_source_dir);
|
||||
test_root = DeprecatedString::formatted("{}/{}", serenity_source_dir, g_test_root_fragment);
|
||||
common_path = DeprecatedString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", serenity_source_dir);
|
||||
#endif
|
||||
}
|
||||
if (!Core::File::is_directory(test_root)) {
|
||||
|
@ -166,7 +166,7 @@ int main(int argc, char** argv)
|
|||
warnln("No test root given, {} requires the SERENITY_SOURCE_DIR environment variable to be set", g_program_name);
|
||||
return 1;
|
||||
}
|
||||
common_path = String::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", serenity_source_dir);
|
||||
common_path = DeprecatedString::formatted("{}/Userland/Libraries/LibJS/Tests/test-common.js", serenity_source_dir);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Test {
|
||||
|
@ -21,15 +21,15 @@ enum class Result {
|
|||
};
|
||||
|
||||
struct Case {
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
Result result;
|
||||
String details;
|
||||
DeprecatedString details;
|
||||
u64 duration_us;
|
||||
};
|
||||
|
||||
struct Suite {
|
||||
String path;
|
||||
String name;
|
||||
DeprecatedString path;
|
||||
DeprecatedString name;
|
||||
// A failed test takes precedence over a skipped test, which both have
|
||||
// precedence over a passed test
|
||||
Result most_severe_test_result { Result::Pass };
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
#include <LibTest/Macros.h> // intentionally first -- we redefine VERIFY and friends in here
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Test {
|
||||
|
||||
|
@ -20,7 +20,7 @@ using TestFunction = Function<void()>;
|
|||
|
||||
class TestCase : public RefCounted<TestCase> {
|
||||
public:
|
||||
TestCase(String const& name, TestFunction&& fn, bool is_benchmark)
|
||||
TestCase(DeprecatedString const& name, TestFunction&& fn, bool is_benchmark)
|
||||
: m_name(name)
|
||||
, m_function(move(fn))
|
||||
, m_is_benchmark(is_benchmark)
|
||||
|
@ -28,11 +28,11 @@ public:
|
|||
}
|
||||
|
||||
bool is_benchmark() const { return m_is_benchmark; }
|
||||
String const& name() const { return m_name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
TestFunction const& func() const { return m_function; }
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
TestFunction m_function;
|
||||
bool m_is_benchmark;
|
||||
};
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibTest/Results.h>
|
||||
#include <LibTest/TestRunnerUtil.h>
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
return s_the;
|
||||
}
|
||||
|
||||
TestRunner(String test_root, bool print_times, bool print_progress, bool print_json, bool detailed_json = false)
|
||||
TestRunner(DeprecatedString test_root, bool print_times, bool print_progress, bool print_json, bool detailed_json = false)
|
||||
: m_test_root(move(test_root))
|
||||
, m_print_times(print_times)
|
||||
, m_print_progress(print_progress)
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
virtual ~TestRunner() { s_the = nullptr; };
|
||||
|
||||
virtual void run(String test_glob);
|
||||
virtual void run(DeprecatedString test_glob);
|
||||
|
||||
Test::Counts const& counts() const { return m_counts; }
|
||||
|
||||
|
@ -63,11 +63,11 @@ protected:
|
|||
void print_test_results() const;
|
||||
void print_test_results_as_json() const;
|
||||
|
||||
virtual Vector<String> get_test_paths() const = 0;
|
||||
virtual void do_run_single_test(String const&, size_t current_test_index, size_t num_tests) = 0;
|
||||
virtual Vector<String> const* get_failed_test_names() const { return nullptr; }
|
||||
virtual Vector<DeprecatedString> get_test_paths() const = 0;
|
||||
virtual void do_run_single_test(DeprecatedString const&, size_t current_test_index, size_t num_tests) = 0;
|
||||
virtual Vector<DeprecatedString> const* get_failed_test_names() const { return nullptr; }
|
||||
|
||||
String m_test_root;
|
||||
DeprecatedString m_test_root;
|
||||
bool m_print_times;
|
||||
bool m_print_progress;
|
||||
bool m_print_json;
|
||||
|
@ -91,7 +91,7 @@ inline void cleanup()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
inline void TestRunner::run(String test_glob)
|
||||
inline void TestRunner::run(DeprecatedString test_glob)
|
||||
{
|
||||
size_t progress_counter = 0;
|
||||
auto test_paths = get_test_paths();
|
||||
|
@ -234,11 +234,11 @@ inline void TestRunner::print_test_results_as_json() const
|
|||
|
||||
auto name = suite.name;
|
||||
if (name == "__$$TOP_LEVEL$$__"sv)
|
||||
name = String::empty();
|
||||
name = DeprecatedString::empty();
|
||||
|
||||
auto path = LexicalPath::relative_path(suite.path, m_test_root);
|
||||
|
||||
tests.set(String::formatted("{}/{}::{}", path, name, case_.name), result_name);
|
||||
tests.set(DeprecatedString::formatted("{}/{}::{}", path, name, case_.name), result_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ inline double get_time_in_ms()
|
|||
}
|
||||
|
||||
template<typename Callback>
|
||||
inline void iterate_directory_recursively(String const& directory_path, Callback callback)
|
||||
inline void iterate_directory_recursively(DeprecatedString const& directory_path, Callback callback)
|
||||
{
|
||||
Core::DirIterator directory_iterator(directory_path, Core::DirIterator::Flags::SkipDots);
|
||||
|
||||
|
@ -32,7 +32,7 @@ inline void iterate_directory_recursively(String const& directory_path, Callback
|
|||
if (fstatat(directory_iterator.fd(), name.characters(), &st, AT_SYMLINK_NOFOLLOW) < 0)
|
||||
continue;
|
||||
bool is_directory = S_ISDIR(st.st_mode);
|
||||
auto full_path = String::formatted("{}/{}", directory_path, name);
|
||||
auto full_path = DeprecatedString::formatted("{}/{}", directory_path, name);
|
||||
if (is_directory && name != "/Fixtures"sv) {
|
||||
iterate_directory_recursively(full_path, callback);
|
||||
} else if (!is_directory) {
|
||||
|
|
|
@ -56,7 +56,7 @@ void set_suite_setup_function(Function<void()> setup)
|
|||
TestSuite::the().set_suite_setup(move(setup));
|
||||
}
|
||||
|
||||
int TestSuite::main(String const& suite_name, int argc, char** argv)
|
||||
int TestSuite::main(DeprecatedString const& suite_name, int argc, char** argv)
|
||||
{
|
||||
m_suite_name = suite_name;
|
||||
|
||||
|
@ -91,7 +91,7 @@ int TestSuite::main(String const& suite_name, int argc, char** argv)
|
|||
return run(matching_tests);
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<TestCase> TestSuite::find_cases(String const& search, bool find_tests, bool find_benchmarks)
|
||||
NonnullRefPtrVector<TestCase> TestSuite::find_cases(DeprecatedString const& search, bool find_tests, bool find_benchmarks)
|
||||
{
|
||||
NonnullRefPtrVector<TestCase> matches;
|
||||
for (auto const& t : m_cases) {
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
#include <LibTest/Macros.h> // intentionally first -- we redefine VERIFY and friends in here
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
namespace Test {
|
||||
|
@ -34,8 +34,8 @@ public:
|
|||
}
|
||||
|
||||
int run(NonnullRefPtrVector<TestCase> const&);
|
||||
int main(String const& suite_name, int argc, char** argv);
|
||||
NonnullRefPtrVector<TestCase> find_cases(String const& search, bool find_tests, bool find_benchmarks);
|
||||
int main(DeprecatedString const& suite_name, int argc, char** argv);
|
||||
NonnullRefPtrVector<TestCase> find_cases(DeprecatedString const& search, bool find_tests, bool find_benchmarks);
|
||||
void add_case(NonnullRefPtr<TestCase> const& test_case)
|
||||
{
|
||||
m_cases.append(test_case);
|
||||
|
@ -50,7 +50,7 @@ private:
|
|||
NonnullRefPtrVector<TestCase> m_cases;
|
||||
u64 m_testtime = 0;
|
||||
u64 m_benchtime = 0;
|
||||
String m_suite_name;
|
||||
DeprecatedString m_suite_name;
|
||||
bool m_current_test_case_passed = true;
|
||||
Function<void()> m_setup;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue