From cbda1a6c73f6f50c7ba2984de3c5d59d08f4102d Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 5 May 2023 12:17:26 -0600 Subject: [PATCH] Meta: Add LibTest and Tests/AK to gn build --- Meta/gn/secondary/BUILD.gn | 3 +- Meta/gn/secondary/Tests/AK/BUILD.gn | 106 ++++++++++++++++++ Meta/gn/secondary/Tests/BUILD.gn | 4 + Meta/gn/secondary/Tests/unittest.gni | 28 +++++ .../Userland/Libraries/LibTest/BUILD.gn | 43 +++++++ 5 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 Meta/gn/secondary/Tests/AK/BUILD.gn create mode 100644 Meta/gn/secondary/Tests/BUILD.gn create mode 100644 Meta/gn/secondary/Tests/unittest.gni create mode 100644 Meta/gn/secondary/Userland/Libraries/LibTest/BUILD.gn diff --git a/Meta/gn/secondary/BUILD.gn b/Meta/gn/secondary/BUILD.gn index c7b8e6283d..d51afb08c3 100644 --- a/Meta/gn/secondary/BUILD.gn +++ b/Meta/gn/secondary/BUILD.gn @@ -1,7 +1,8 @@ import("//Meta/gn/build/toolchain/compiler.gni") group("default") { - deps = [ "//Userland/Libraries/LibCore" ] + deps = [ "//Tests" ] + testonly = true } # A pool called "console" in the root BUILD.gn is magic and represents ninja's diff --git a/Meta/gn/secondary/Tests/AK/BUILD.gn b/Meta/gn/secondary/Tests/AK/BUILD.gn new file mode 100644 index 0000000000..b064999b47 --- /dev/null +++ b/Meta/gn/secondary/Tests/AK/BUILD.gn @@ -0,0 +1,106 @@ +import("//Tests/unittest.gni") + +tests = [ + "TestAllOf", + "TestAnyOf", + "TestArbitrarySizedEnum", + "TestArray", + "TestAtomic", + "TestBadge", + "TestBase64", + "TestBinaryHeap", + "TestBinarySearch", + "TestBitCast", + "TestBitmap", + "TestBitStream", + "TestBuiltinWrappers", + "TestByteBuffer", + "TestCharacterTypes", + "TestChecked", + "TestCircularBuffer", + "TestCircularDeque", + "TestCircularQueue", + "TestComplex", + "TestDeprecatedString", + "TestDisjointChunks", + "TestDistinctNumeric", + "TestDoublyLinkedList", + "TestDuration", + "TestEndian", + "TestEnumBits", + "TestFind", + "TestFixedArray", + "TestFixedPoint", + "TestFloatingPoint", + "TestFloatingPointParsing", + "TestFlyString", + "TestFormat", + "TestGenericLexer", + "TestHashFunctions", + "TestHashMap", + "TestHashTable", + "TestHex", + "TestIPv4Address", + "TestIPv6Address", + "TestIndexSequence", + "TestInsertionSort", + "TestIntegerMath", + "TestIntrusiveList", + "TestIntrusiveRedBlackTree", + "TestJSON", + "TestLEB128", + "TestLexicalPath", + "TestMACAddress", + "TestMemory", + "TestMemoryStream", + "TestNeverDestroyed", + "TestNonnullRefPtr", + "TestNumberFormat", + "TestOptional", + "TestOwnPtr", + "TestPrint", + "TestQueue", + "TestQuickSelect", + "TestQuickSort", + "TestRedBlackTree", + "TestRefPtr", + "TestSIMD", + "TestSinglyLinkedList", + "TestSourceGenerator", + "TestSourceLocation", + "TestSpan", + "TestStack", + "TestStatistics", + "TestStdLibExtras", + "TestStringFloatingPointConversions", + "TestStringUtils", + "TestStringView", + "TestTrie", + "TestTuple", + "TestTypeTraits", + "TestTypedTransfer", + "TestUFixedBigInt", + "TestURL", + "TestUtf16", + "TestUtf8", + "TestVariant", + "TestVector", + "TestWeakPtr", +] + +# FIXME: "TestString", when LibUnicode is available + +foreach(test_name, tests) { + unittest(test_name) { + include_dirs = [ "//Userland/Libraries" ] + sources = [ test_name + ".cpp" ] + } +} + +group("AK") { + deps = [] + foreach(test_name, tests) { + deps += [ ":" + test_name ] + } + testonly = true +} diff --git a/Meta/gn/secondary/Tests/BUILD.gn b/Meta/gn/secondary/Tests/BUILD.gn new file mode 100644 index 0000000000..941900eedd --- /dev/null +++ b/Meta/gn/secondary/Tests/BUILD.gn @@ -0,0 +1,4 @@ +group("Tests") { + deps = [ "//Tests/AK" ] + testonly = true +} diff --git a/Meta/gn/secondary/Tests/unittest.gni b/Meta/gn/secondary/Tests/unittest.gni new file mode 100644 index 0000000000..7a4d0848e5 --- /dev/null +++ b/Meta/gn/secondary/Tests/unittest.gni @@ -0,0 +1,28 @@ +template("unittest") { + executable(target_name) { + has_custom_main = false + use_js_main = false + + # Foward everything (has_custom_main if set; configs, sources, deps, ...). + forward_variables_from(invoker, "*") + assert(!defined(invoker.output_dir), "cannot set unittest output_dir") + assert(!defined(invoker.testonly), "cannot set unittest testonly") + + output_dir = target_out_dir + + deps = [ "//AK" ] + if (has_custom_main) { + deps += [ "//Userland/Libraries/LibTest" ] + } else if (use_js_main) { + deps += [ "//Userland/Libraries/LibTest:test_js_main" ] + } else { + deps += [ "//Userland/Libraries/LibTest:test_main" ] + } + + if (current_os != "serenity") { + deps += [ "//Userland/Libraries/LibCore" ] + } + + testonly = true + } +} diff --git a/Meta/gn/secondary/Userland/Libraries/LibTest/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibTest/BUILD.gn new file mode 100644 index 0000000000..8828a9d484 --- /dev/null +++ b/Meta/gn/secondary/Userland/Libraries/LibTest/BUILD.gn @@ -0,0 +1,43 @@ +shared_library("LibTest") { + output_name = "test" + include_dirs = [ "//Userland/Libraries" ] + sources = [ + "CrashTest.cpp", + "CrashTest.h", + "Macros.h", + "Results.h", + "TestCase.h", + "TestRunner.h", + "TestRunnerUtil.h", + "TestSuite.cpp", + "TestSuite.h", + ] + + deps = [ "//AK" ] + if (current_os != "serenity") { + deps += [ "//Userland/Libraries/LibCore" ] + } + + output_name = "test" + + testonly = true +} + +source_set("test_main") { + include_dirs = [ "//Userland/Libraries" ] + sources = [ "TestMain.cpp" ] + deps = [ "//AK" ] + public_deps = [ ":LibTest" ] + testonly = true +} + +source_set("test_js_main") { + include_dirs = [ "//Userland/Libraries" ] + sources = [ + "JavaScriptTestRunner.h", + "JavaScriptTestRunnerMain.cpp", + ] + deps = [ "//AK" ] + public_deps = [ ":LibTest" ] + testonly = true +}