From d0b321bc0cedcb9b27ca782faf52f6694c4f3988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pedro=20Bol=C3=ADvar=20Puente?= Date: Tue, 25 Jul 2017 00:21:55 +0200 Subject: [PATCH] Sketch Guile tests --- .dir-locals.el | 2 ++ test/CMakeLists.txt | 28 ++++++++++++++++++---------- test/tests.scm | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 .dir-locals.el create mode 100644 test/tests.scm diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..760c7fb --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((scheme-mode + (eval put 'test-group 'scheme-indent-function 1))) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9948774..9e2dd21 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,9 +3,8 @@ # ====== set(CATCH_INCLUDE_DIR "${DEPS_DIR}/Source/catch/single_include") - -set(GGSPEC "${DEPS_DIR}/Source/ggspec/ggspec") set(GGSPEC_MODULE_DIR "${DEPS_DIR}/Source") +set(GUILE "guile") # Dependencies # ============ @@ -30,8 +29,8 @@ add_dependencies(tests examples) add_dependencies(check tests) # Build and run C++ unit tests -file(GLOB_RECURSE schmutz_unit_tests "*.test.cpp") -foreach(_file IN LISTS schmutz_unit_tests) +file(GLOB_RECURSE schmutz_cpp_unit_tests "*.test.cpp") +foreach(_file IN LISTS schmutz_cpp_unit_tests) schmutz_target_name_for(_target _output "${_file}") add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") set_target_properties(${_target} PROPERTIES OUTPUT_NAME ${_output}) @@ -46,15 +45,24 @@ foreach(_file IN LISTS schmutz_unit_tests) add_test("test/${_output}" ${_output}) endforeach() -# Build Guile extensions and run all guile unit tests +# Build Guile extensions that are needed for the unit tests to run file(GLOB_RECURSE schmutz_unit_tests "*.scm.cpp") foreach(_file IN LISTS schmutz_unit_tests) schmutz_target_name_for(_target _output "${_file}") - add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") - add_dependencies(tests ${_target}) + # build the library.so file + add_library(${_target} SHARED EXCLUDE_FROM_ALL "${_file}") + add_dependencies(examples ${_target}) set_target_properties(${_target} PROPERTIES OUTPUT_NAME ${_output}) target_link_libraries(${_target} PUBLIC schmutz) + # build the library.scm file + set(GUILE_EXTENSION_DIR ${CMAKE_CURRENT_BINARY_DIR}) + configure_file(${_output}.scm.in ${_output}.scm) +endforeach() + +file(GLOB_RECURSE schmutz_scm_unit_tests "*.scm") +foreach(_file IN LISTS schmutz_scm_unit_tests) + schmutz_target_name_for(_target _output "${_file}") + add_test("test/${_output}" ${GUILE} ${_file}) + set_tests_properties("test/${_output}" PROPERTIES + ENVIRONMENT GUILE_LOAD_PATH=${GGSPEC_MODULE_DIR}:${CMAKE_BUILD_DIR}) endforeach() -add_test("test/ggspec" ${GGSPEC}) -set_tests_properties("test/ggspec" PROPERTIES - ENVIRONMENT GUILE_LOAD_PATH=${GGSPEC_MODULE_DIR}) diff --git a/test/tests.scm b/test/tests.scm new file mode 100644 index 0000000..0a49d88 --- /dev/null +++ b/test/tests.scm @@ -0,0 +1,19 @@ +;; +;; schmutz - Scheme Unterstüzung +;; +;; Copyright (C) 2017 Juan Pedro Bolivar Puente +;; Distributed under the Boost Software License, Version 1.0. +;; See accompanying file LICENSE or at: http://boost.org/LICENSE_1_0.txt +;; + +(use-modules (srfi srfi-64)) + +(test-runner-current (test-runner-create)) + +(test-group "some tests1" + (test-eq 42 (* 21 2))) + +(test-group "some tests2" + (test-assert (= 42 (* 21 2)))) + +(exit (test-runner-fail-count (test-runner-current)))