Replace catch2 with google test

This commit is contained in:
Sameer Rahmani 2023-08-15 21:50:16 +01:00
parent 97c1b3e7c1
commit 3e2aaea218
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
6 changed files with 88 additions and 13 deletions

View File

@ -32,7 +32,7 @@ cmake_policy(SET CMP0116 OLD)
# User Options
# =============================================================================
option(CPP_20_SUPPORT "C++20 Support" ON)
option(SERENE_BUILD_TESTING "Enable tests" OFF)
option(SERENE_BUILD_TESTING "Enable tests" ON)
option(SERENE_ENABLE_BUILDID "Enable build id." OFF)
option(SERENE_ENABLE_THINLTO "Enable ThisLTO." ON)
option(SERENE_ENABLE_DOCS "Enable document generation" OFF)
@ -132,15 +132,16 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
Include(FetchContent)
if(SERENE_BUILD_TESTING)
message(STATUS "Fetching Catch2 v3...")
message(STATUS "Fetching google test...")
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.0-preview4
)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP ON
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
# LLVM setup ==================================================================

View File

@ -134,3 +134,8 @@ install(TARGETS serene EXPORT SereneTargets
add_subdirectory(src)
add_subdirectory(include)
if(SERENE_BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()

View File

@ -19,6 +19,7 @@
#include "jit/jit.h"
#include "options.h" // for Options
#include "source_mgr.h"
#include <__type_traits/remove_reference.h> // for remov...
#include <__utility/move.h> // for move
@ -130,9 +131,7 @@ size_t JIT::getNumberOfJITDylibs(const llvm::StringRef &nsName) {
JIT::JIT(llvm::orc::JITTargetMachineBuilder &&jtmb,
std::unique_ptr<Options> opts)
:
options(std::move(opts)),
: options(std::move(opts)),
cache(options->JITenableObjectCache ? new ObjectCache() : nullptr),
gdbListener(options->JITenableGDBNotificationListener
? llvm::JITEventListener::createGDBRegistrationListener()

View File

@ -27,6 +27,7 @@
#define JIT_JIT_H
#include "options.h"
#include "source_mgr.h"
#include <__memory/unique_ptr.h>
@ -60,7 +61,7 @@ class LLLazyJIT;
} // namespace llvm::orc
namespace serene {
class Namespace;
class SourceMgr;
} // namespace serene
#define MAIN_PROCESS_JD_NAME "*main*"
@ -109,6 +110,9 @@ class JIT {
std::vector<const char *> loadPaths;
// The source manager is the owner of all the sources and there can be
// just one source manager.
SourceMgr srcMgr;
// We keep the jibDylibs for each name space in a mapping from the ns
// name to a vector of jitdylibs, the last element is always the newest
// jitDylib

View File

@ -0,0 +1,43 @@
# Serene Programming Language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if(SERENE_BUILD_TESTING)
include(GoogleTest)
add_executable(serene_test
reader_tests.cpp
)
target_link_libraries(serene_test PRIVATE
GTest::gtest_main
LLVMSupport)
target_include_directories(serene_test
SYSTEM PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../include
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
target_include_directories(serene_test SYSTEM PUBLIC
# We don't want the generated files from table gen
# to be treated as local since the contain warnings
${PROJECT_BINARY_DIR}/serene/include)
gtest_discover_tests(serene_test)
endif()

View File

@ -0,0 +1,23 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "reader.h"
#include <gtest/gtest.h>
TEST(Reader, ReadNumber) { EXPECT_EQ(1, 1); }