summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-02-25 19:35:48 +0100
committerVivien Kraus <vivien@planete-kraus.eu>2021-02-25 19:57:09 +0100
commit100d22bdd9b099d292fbe2f0c2f576de471732dc (patch)
tree32f740dd9a4600f4b0cca3b9bba466a6c6084187
parent286a2cfc0395f0a689413767c4d90d4be44e810e (diff)
Use a separate module for tests0.3.5
-rw-r--r--Makefile.am29
-rw-r--r--web-client-with-cache.org44
2 files changed, 60 insertions, 13 deletions
diff --git a/Makefile.am b/Makefile.am
index aecdf2a..0370d5f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,13 +37,25 @@ SUFFIXES = .scm .go
$(install_go_targets): $(install_mod_targets)
-$(srcdir)/web/client/with-cache.scm: web-client-with-cache.org
+$(srcdir)/web/client/with-cache.scm $(srcdir)/tests/tests.scm: web-client-with-cache.org
+ @$(MKDIR_P) tangling
+ @cp $< tangling/web-client-with-cache.org
$(AM_V_GEN) $(EMACS) --batch \
- --file $(srcdir)/$< \
+ --file tangling/$< \
--eval "(setq org-confirm-babel-evaluate nil)" \
--eval "(setq geiser-scheme-implementation 'guile)" \
- -f org-babel-tangle \
- || rm -f web/client/with-cache.scm
+ -f org-babel-tangle || exit 1
+ @$(MKDIR_P) $(abs_top_srcdir)/web/client
+ @$(MKDIR_P) $(abs_top_srcdir)/tests
+ @mv tangling/web/client/with-cache.scm $(abs_top_srcdir)/web/client/with-cache.scm
+ @mv tangling/tests/tests.scm $(abs_top_srcdir)/tests/tests.scm
+ @rmdir tangling/web/client
+ @rmdir tangling/web
+ @rmdir tangling/tests
+ @rm tangling/$<
+ @rmdir tangling
+
+$(srcdir)/tests/tests.scm: $(srcdir)/web/client/with-cache.scm
$(srcdir)/doc/web-client-with-cache.texi: web-client-with-cache.org
$(AM_V_GEN) $(EMACS) --batch \
@@ -53,5 +65,10 @@ $(srcdir)/doc/web-client-with-cache.texi: web-client-with-cache.org
-f org-texinfo-export-to-texinfo
@mv web-client-with-cache.texi doc/web-client-with-cache.texi
-check-local: pre-inst-env web/client/with-cache.scm
- ./pre-inst-env guile -c "(begin (use-modules (web client with-cache)) (run-tests))"
+TESTS = tests/tests.scm
+
+TEST_EXTENSIONS = .scm
+
+AM_TESTS_ENVIRONMENT = $(top_builddir)/pre-inst-env
+SCM_LOG_COMPILER = $(GUILE)
+AM_SCM_LOG_FLAGS = --no-auto-compile -s
diff --git a/web-client-with-cache.org b/web-client-with-cache.org
index 6e89072..eed7a8d 100644
--- a/web-client-with-cache.org
+++ b/web-client-with-cache.org
@@ -57,9 +57,9 @@ looks like this:
#+begin_src scheme :eval no
(cons (channel
- (name 'web-client-with-cache)
- (url "https://labo.planete-kraus.eu/web-client-with-cache.git"))
- %default-channels)
+ (name 'web-client-with-cache)
+ (url "https://labo.planete-kraus.eu/web-client-with-cache.git"))
+ %default-channels)
#+end_src
Then, run guix pull:
@@ -597,9 +597,6 @@ The final function is [[fn-with-cache]]. It takes its docstring from
<<fn-with-cache-query>>
(lambda (uri . args)
(apply with-cache-query box (current-time) smart-http-get http-get uri args))))
-
- (define-public (run-tests)
- <<tests>>)
#+end_src
* Test cases
@@ -921,13 +918,46 @@ Let's see immediately an example, program [[test-1]].
** All the tests :noexport:
#+name: tests
-#+begin_src scheme :eval no :noweb yes
+#+begin_src scheme :eval no :noweb yes :tangle tests/tests.scm :mkdirp t
+ (define-module (tests-harness)
+ #:use-module (web client with-cache)
+ #:use-module (web response)
+ #:use-module (ice-9 atomic)
+ #:use-module (ice-9 receive)
+ #:use-module (srfi srfi-19)
+ #:use-module (srfi srfi-64)
+ #:use-module (srfi srfi-69))
+
+ (module-define! (resolve-module '(srfi srfi-64))
+ 'test-log-to-file #f)
+
<<fn-run-test-case>>
+
+ (test-begin "test-1")
+
<<test-1>>
+
+ (test-end "test-1")
+ (test-begin "test-2")
+
<<test-2>>
+
+ (test-end "test-2")
+ (test-begin "test-3")
+
<<test-3>>
+
+ (test-end "test-3")
+ (test-begin "test-4")
+
<<test-4>>
+
+ (test-end "test-4")
+ (test-begin "test-5")
+
<<test-5>>
+
+ (test-end "test-5")
#+end_src
* GNU Free Documentation License
:PROPERTIES: