Skip to content

Commit

Permalink
Sketch Guile tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arximboldi committed Jul 24, 2017
1 parent a86b665 commit d0b321b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((scheme-mode
(eval put 'test-group 'scheme-indent-function 1)))
28 changes: 18 additions & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ============
Expand All @@ -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})
Expand All @@ -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})
19 changes: 19 additions & 0 deletions test/tests.scm
Original file line number Diff line number Diff line change
@@ -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)))

0 comments on commit d0b321b

Please sign in to comment.