1
0
mirror of https://github.com/nomic-ai/gpt4all.git synced 2025-05-08 00:17:20 +00:00

Add test scaffolding ()

Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Co-authored-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
AT 2024-10-18 15:27:03 -04:00 committed by GitHub
parent c3357b7625
commit 9cafd38dcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 57 additions and 0 deletions

View File

@ -22,6 +22,9 @@ if(APPLE)
endif()
endif()
find_package(Python3 QUIET COMPONENTS Interpreter)
option(GPT4ALL_TEST "Build the tests" ${Python3_FOUND})
option(GPT4ALL_LOCALHOST "Build installer for localhost repo" OFF)
option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF)
option(GPT4ALL_SIGN_INSTALL "Sign installed binaries and installers (requires signing identities)" OFF)
@ -93,6 +96,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_subdirectory(deps)
add_subdirectory(../gpt4all-backend llmodel)
if (GPT4ALL_TEST)
enable_testing()
add_subdirectory(tests)
# The 'check' target makes sure the tests and their dependencies are up-to-date before running them
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS chat gpt4all_tests)
endif()
set(CHAT_EXE_RESOURCES)
# Metal shader library

View File

@ -0,0 +1,28 @@
include(FetchContent)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
# Google test download and setup
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip
)
FetchContent_MakeAvailable(googletest)
add_test(NAME ChatPythonTests
COMMAND ${Python3_EXECUTABLE} -m pytest ${CMAKE_SOURCE_DIR}/tests/python_tests
)
set_tests_properties(ChatPythonTests PROPERTIES
ENVIRONMENT "CHAT_EXECUTABLE=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/chat"
TIMEOUT 60
)
add_executable(gpt4all_tests
test_main.cpp
basic_test.cpp
)
target_link_libraries(gpt4all_tests PRIVATE gtest gtest_main)
include(GoogleTest)
gtest_discover_tests(gpt4all_tests)

View File

@ -0,0 +1,5 @@
#include <gtest/gtest.h>
TEST(BasicTest, TestInitialization) {
EXPECT_TRUE(true);
}

View File

@ -0,0 +1,7 @@
import os
import pytest
# test that the chat executable exists
def test_chat_environment():
assert os.path.exists(os.environ['CHAT_EXECUTABLE'])

View File

@ -0,0 +1,6 @@
#include <gtest/gtest.h>
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}