File tree Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ if(APPLE)
2222  endif ()
2323endif ()
2424
25+ find_package (Python3 QUIET  COMPONENTS Interpreter)
26+ 
27+ option (GPT4ALL_TEST "Build the tests"  ${Python3_FOUND} )
2528option (GPT4ALL_LOCALHOST "Build installer for localhost repo"  OFF )
2629option (GPT4ALL_OFFLINE_INSTALLER "Build an offline installer"  OFF )
2730option (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)
9396add_subdirectory (deps)
9497add_subdirectory (../gpt4all-backend llmodel)
9598
99+ if  (GPT4ALL_TEST)
100+     enable_testing ()
101+     add_subdirectory (tests)
102+ 
103+     # The 'check' target makes sure the tests and their dependencies are up-to-date before running them 
104+     add_custom_target (check COMMAND  ${CMAKE_CTEST_COMMAND}  DEPENDS  chat gpt4all_tests)
105+ endif ()
106+ 
96107set (CHAT_EXE_RESOURCES)
97108
98109# Metal shader library 
Original file line number Diff line number Diff line change 1+ include (FetchContent)
2+ 
3+ find_package (Python3 REQUIRED COMPONENTS Interpreter)
4+ 
5+ # Google test download and setup 
6+ FetchContent_Declare(
7+     googletest
8+     URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip
9+ )
10+ FetchContent_MakeAvailable(googletest)
11+ 
12+ add_test (NAME  ChatPythonTests
13+     COMMAND  ${Python3_EXECUTABLE}  -m pytest ${CMAKE_SOURCE_DIR} /tests/python_tests
14+ )
15+ set_tests_properties (ChatPythonTests PROPERTIES
16+     ENVIRONMENT  "CHAT_EXECUTABLE=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /chat" 
17+     TIMEOUT  60
18+ )
19+ 
20+ add_executable (gpt4all_tests
21+     test_main.cpp
22+     basic_test.cpp
23+ )
24+ 
25+ target_link_libraries (gpt4all_tests PRIVATE  gtest gtest_main)
26+ 
27+ include (GoogleTest)
28+ gtest_discover_tests(gpt4all_tests)
Original file line number Diff line number Diff line change 1+ #include  < gtest/gtest.h> 
2+ 
3+ TEST (BasicTest, TestInitialization) {
4+     EXPECT_TRUE (true );
5+ }
Original file line number Diff line number Diff line change 1+ import  os 
2+ 
3+ import  pytest 
4+ 
5+ # test that the chat executable exists 
6+ def  test_chat_environment ():
7+     assert  os .path .exists (os .environ ['CHAT_EXECUTABLE' ])
Original file line number Diff line number Diff line change 1+ #include  < gtest/gtest.h> 
2+ 
3+ int  main (int  argc, char  **argv) {
4+     ::testing::InitGoogleTest (&argc, argv);
5+     return  RUN_ALL_TESTS ();
6+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments