mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibTest: Explicitly export symbols
This commit is contained in:
parent
2194cbde4b
commit
d35486cb74
Notes:
github-actions[bot]
2025-05-16 19:24:56 +00:00
Author: https://github.com/ayeteadoe
Commit: d35486cb74
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4698
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/R-Goc
7 changed files with 33 additions and 25 deletions
|
@ -9,5 +9,6 @@ set(SOURCES
|
|||
)
|
||||
|
||||
add_library(LibTest ${SOURCES})
|
||||
lagom_generate_export_header(LibTest test)
|
||||
target_link_libraries(LibTest PRIVATE AK LibCore LibFileSystem)
|
||||
set_target_properties(LibTest PROPERTIES OUTPUT_NAME lagom-test)
|
||||
|
|
|
@ -11,10 +11,11 @@
|
|||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibTest/Export.h>
|
||||
|
||||
namespace Test {
|
||||
|
||||
class Crash {
|
||||
class TEST_API Crash {
|
||||
public:
|
||||
enum class RunType {
|
||||
UsingChildProcess,
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/Math.h>
|
||||
#include <AK/SourceLocation.h>
|
||||
#include <LibTest/CrashTest.h>
|
||||
#include <LibTest/Export.h>
|
||||
#include <LibTest/Randomized/RandomnessSource.h>
|
||||
#include <LibTest/TestResult.h>
|
||||
|
||||
|
@ -19,16 +20,16 @@ namespace Test {
|
|||
|
||||
// Declare helpers so that we can call them from VERIFY in included headers
|
||||
// the setter for TestResult is already declared in TestResult.h
|
||||
TestResult current_test_result();
|
||||
TEST_API TestResult current_test_result();
|
||||
|
||||
Randomized::RandomnessSource& randomness_source();
|
||||
void set_randomness_source(Randomized::RandomnessSource);
|
||||
TEST_API Randomized::RandomnessSource& randomness_source();
|
||||
TEST_API void set_randomness_source(Randomized::RandomnessSource);
|
||||
|
||||
bool is_reporting_enabled();
|
||||
void enable_reporting();
|
||||
void disable_reporting();
|
||||
TEST_API bool is_reporting_enabled();
|
||||
TEST_API void enable_reporting();
|
||||
TEST_API void disable_reporting();
|
||||
|
||||
u64 randomized_runs();
|
||||
TEST_API u64 randomized_runs();
|
||||
|
||||
template<typename T>
|
||||
void expect(T const& expression, StringView expression_string, SourceLocation location = SourceLocation::current())
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibTest/Export.h>
|
||||
#include <LibTest/Macros.h>
|
||||
#include <LibTest/Randomized/RandomnessSource.h>
|
||||
#include <LibTest/Randomized/Shrink.h>
|
||||
|
@ -29,7 +30,7 @@ inline void run_with_randomness_source(Randomized::RandomnessSource source, Test
|
|||
}
|
||||
}
|
||||
|
||||
class TestCase : public RefCounted<TestCase> {
|
||||
class TEST_API TestCase : public RefCounted<TestCase> {
|
||||
public:
|
||||
TestCase(ByteString const& name, TestFunction&& fn, bool is_benchmark)
|
||||
: m_name(name)
|
||||
|
@ -107,9 +108,8 @@ private:
|
|||
};
|
||||
|
||||
// Helper to hide implementation of TestSuite from users
|
||||
void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case);
|
||||
void set_suite_setup_function(Function<void()> setup);
|
||||
|
||||
TEST_API void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case);
|
||||
TEST_API void set_suite_setup_function(Function<void()> setup);
|
||||
}
|
||||
|
||||
#define TEST_SETUP \
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibTest/Export.h>
|
||||
|
||||
namespace Test {
|
||||
|
||||
// TestResult signals to the TestSuite how the TestCase execution went.
|
||||
|
@ -30,6 +32,6 @@ enum class TestResult {
|
|||
|
||||
// Used eg. to signal we've ran out of prerecorded random bits.
|
||||
// Defined in TestSuite.cpp
|
||||
void set_current_test_result(TestResult);
|
||||
void TEST_API set_current_test_result(TestResult);
|
||||
|
||||
} // namespace Test
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibTest/Export.h>
|
||||
#include <LibTest/Macros.h>
|
||||
#include <LibTest/Randomized/RandomnessSource.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
@ -18,7 +19,7 @@
|
|||
|
||||
namespace Test {
|
||||
|
||||
class TestSuite {
|
||||
class TEST_API TestSuite {
|
||||
public:
|
||||
static TestSuite& the()
|
||||
{
|
||||
|
|
|
@ -178,6 +178,18 @@ if (WIN32)
|
|||
find_package(mman REQUIRED)
|
||||
endif()
|
||||
|
||||
function(lagom_generate_export_header name fs_name)
|
||||
# Temporary helper to allow libraries to opt-in to using X_API macros
|
||||
# to export symbols required by external consumers. This allows the codebase
|
||||
# to gradually slowly migrate instead of an all-or-nothing approach.
|
||||
if (NOT WIN32)
|
||||
target_compile_options(${name} PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
include(GenerateExportHeader)
|
||||
string(TOUPPER ${fs_name} fs_name_upper)
|
||||
generate_export_header(${name} EXPORT_MACRO_NAME ${fs_name_upper}_API EXPORT_FILE_NAME "Export.h")
|
||||
endfunction()
|
||||
|
||||
function(lagom_lib target_name fs_name)
|
||||
cmake_parse_arguments(LAGOM_LIBRARY "EXPLICIT_SYMBOL_EXPORT" "LIBRARY_TYPE" "SOURCES;LIBS" ${ARGN})
|
||||
string(REPLACE "Lib" "" library ${target_name})
|
||||
|
@ -225,18 +237,8 @@ function(lagom_lib target_name fs_name)
|
|||
)
|
||||
endif()
|
||||
serenity_generated_sources(${target_name})
|
||||
|
||||
if (LAGOM_LIBRARY_EXPLICIT_SYMBOL_EXPORT)
|
||||
# Temporary helper to allow libraries to opt-in to using X_API macros
|
||||
# to export symbols required by external consumers. This allows the codebase
|
||||
# to gradually slowly migrate instead of an all-or-nothing approach.
|
||||
if (NOT WIN32)
|
||||
target_compile_options(${target_name} PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
include(GenerateExportHeader)
|
||||
string(TOUPPER ${fs_name} fs_name_upper)
|
||||
generate_export_header(${target_name} EXPORT_MACRO_NAME "${fs_name_upper}_API" EXPORT_FILE_NAME "Export.h")
|
||||
target_sources(${target_name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/Export.h")
|
||||
lagom_generate_export_header(${target_name} ${fs_name})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue