From 9d173e23bc0bf39c1114f2ac6fc6e5c1e56dd55f Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Tue, 10 May 2016 01:06:10 +0200 Subject: job-specifier: range: Add tests. * build-aux/test-driver.scm: New script. * configure.ac (AC_REQUIRE_AUX_FILE): Add it. * tests/job-specifier.scm: New test. * Makefile.am (TEST_EXTENSIONS, AM_TESTS_ENVIRONMENT, SCM_LOG_DRIVER) (TESTS): New variables. (EXTRA_DIST): Update. * .gitignore: Likewise. --- tests/job-specifier.scm | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/job-specifier.scm (limited to 'tests') diff --git a/tests/job-specifier.scm b/tests/job-specifier.scm new file mode 100644 index 0000000..889530b --- /dev/null +++ b/tests/job-specifier.scm @@ -0,0 +1,43 @@ +;;;; job-specifier.scm -- tests for (mcron job-specifier) module +;;; Copyright © 2016 Mathieu Lirzin +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . + +(use-modules (srfi srfi-64) + (mcron job-specifier)) + +(test-begin "job-specifier") + +(test-equal "range: basic" + '(0 1 2 3 4 5 6 7 8 9) + (range 0 10)) + +(test-equal "range: positive step" + '(0 2 4 6 8) + (range 0 10 2)) + +(test-assert "range: zero step" + ;; Since this behavior is undefined, only check if range doesn't crash. + (range 0 5 0)) + +(test-assert "range: negative step" + ;; Since this behavior is undefined, only check if range doesn't crash. + (range 0 5 -2)) + +(test-assert "range: reverse boundaries" + (range 10 3)) + +(test-end) -- cgit v1.2.3 From e9fde01d27e25847efb5e9bec9f9dfd9fd8478bf Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Tue, 10 May 2016 02:22:09 +0200 Subject: environment: modify-environment: Add tests. * tests/environment.scm: New test. * Makefile.am (TESTS): Add it. --- Makefile.am | 4 +++- tests/environment.scm | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/environment.scm (limited to 'tests') diff --git a/Makefile.am b/Makefile.am index 020aac6..c878685 100644 --- a/Makefile.am +++ b/Makefile.am @@ -68,7 +68,9 @@ SCM_LOG_DRIVER = \ $(builddir)/pre-inst-env $(GUILE) \ $(srcdir)/build-aux/test-driver.scm -TESTS = tests/job-specifier.scm +TESTS = \ + tests/environment.scm \ + tests/job-specifier.scm # Unset 'GUILE_LOAD_COMPILED_PATH' altogether while compiling. Otherwise, if # $GUILE_LOAD_COMPILED_PATH contains $(mcronmoduledir), we may find .go files diff --git a/tests/environment.scm b/tests/environment.scm new file mode 100644 index 0000000..1bc34a6 --- /dev/null +++ b/tests/environment.scm @@ -0,0 +1,39 @@ +;;;; environment.scm -- tests for (mcron environment) module +;;; Copyright © 2016 Mathieu Lirzin +;;; +;;; This file is part of GNU Mcron. +;;; +;;; GNU Mcron is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Mcron is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Mcron. If not, see . + +(use-modules (srfi srfi-64) + (mcron environment)) + +(test-begin "environment") + +(test-assert "modifiy-environment: basic" + (begin + (modify-environment '(("FOO" . "bar")) (getpw)) + (equal? (getenv "FOO") "bar"))) + +(test-assert "modifiy-environment: user & logname" + ;; Check that USER and LOGNAME environment variables can't be changed. + (let* ((user-entry (pk (getpw))) + (user-name (passwd:name user-entry))) + (modify-environment '(("USER" . "alice")) user-entry) + (modify-environment '(("LOGNAME" . "bob")) user-entry) + (equal? user-name + (pk (getenv "USER")) + (pk (getenv "LOGNAME"))))) + +(test-end) -- cgit v1.2.3