mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-26 07:23:38 +00:00
Add test scaffolding (#3103)
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:
parent
c3357b7625
commit
9cafd38dcf
@ -22,6 +22,9 @@ if(APPLE)
|
|||||||
endif()
|
endif()
|
||||||
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_LOCALHOST "Build installer for localhost repo" OFF)
|
||||||
option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF)
|
option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF)
|
||||||
option(GPT4ALL_SIGN_INSTALL "Sign installed binaries and installers (requires signing identities)" 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(deps)
|
||||||
add_subdirectory(../gpt4all-backend llmodel)
|
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)
|
set(CHAT_EXE_RESOURCES)
|
||||||
|
|
||||||
# Metal shader library
|
# Metal shader library
|
||||||
|
28
gpt4all-chat/tests/CMakeLists.txt
Normal file
28
gpt4all-chat/tests/CMakeLists.txt
Normal 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)
|
5
gpt4all-chat/tests/basic_test.cpp
Normal file
5
gpt4all-chat/tests/basic_test.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(BasicTest, TestInitialization) {
|
||||||
|
EXPECT_TRUE(true);
|
||||||
|
}
|
7
gpt4all-chat/tests/python_tests/test_executable.py
Normal file
7
gpt4all-chat/tests/python_tests/test_executable.py
Normal 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'])
|
6
gpt4all-chat/tests/test_main.cpp
Normal file
6
gpt4all-chat/tests/test_main.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user