You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.3 KiB

cmake_minimum_required(VERSION 3.24)
project(UserScript)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(FETCHCONTENT_QUIET OFF)
set(CATCH_CONFIG_DISABLE_EXCEPTIONS ON)
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.3.2
)
FetchContent_MakeAvailable(Catch2)
enable_testing()
include(CTest)
include(Catch)
add_library(UserScript STATIC
include/UserScript.h
priv_include/UserScript/interpreter.h
src/generator.cpp
src/interpreter.cpp
src/lex.cpp
src/parse.cpp src/std/array.cpp src/std/crypto.cpp include/UserScriptRequire.h include/UserScriptWizardry.h src/std/utils.cpp)
target_include_directories(UserScript PUBLIC include)
include_directories(priv_include)
add_executable(ushell script_exe/main.cpp)
target_link_libraries(ushell PUBLIC UserScript)
add_executable(userscript_tests tests/lexer_test.cpp tests/parser_test.cpp)
target_link_libraries(userscript_tests PUBLIC UserScript Catch2::Catch2WithMain)
catch_discover_tests(userscript_tests)
function(add_script_test [testname filename resultname])
message("Added test: ${ARGV0}")
add_test(
NAME "${ARGV0}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMAND $<TARGET_FILE:ushell> "compare" "${ARGV1}" "${ARGV2}"
)
endfunction()
add_script_test("Scripting 001: Operators" tests/scripts/001.script tests/scripts/001.results)
add_script_test("Scripting 002: Statements and Conditionals" tests/scripts/002.script tests/scripts/002.results)
add_script_test("Scripting 003: While loops" tests/scripts/003.script tests/scripts/003.results)
add_script_test("Scripting 004: While loops with bad terminator" tests/scripts/004.script tests/scripts/004.results)
add_script_test("Scripting 005: If statements with bad terminator" tests/scripts/005.script tests/scripts/005.results)
add_script_test("Scripting 006: The stack is properly purged" tests/scripts/006.script tests/scripts/006.results)
add_script_test("Scripting 007: Cryptography seems to work" tests/scripts/007.script tests/scripts/007.results)
add_script_test("Scripting 008: Utils seems to work" tests/scripts/008.script tests/scripts/008.results)