diff options
author | Eric Bavier <bavier@member.fsf.org> | 2015-01-08 14:41:15 -0600 |
---|---|---|
committer | Eric Bavier <bavier@member.fsf.org> | 2015-01-09 10:38:25 -0600 |
commit | 694b317c2dfac5f8b284a5831e20d89cc112bd6b (patch) | |
tree | 35be0154e39a3d9e7cc6de702263def0e9525640 /guix | |
parent | 1ff2619bc114aface6b7b9d818f7208f9af677df (diff) | |
download | gnu-guix-694b317c2dfac5f8b284a5831e20d89cc112bd6b.tar gnu-guix-694b317c2dfac5f8b284a5831e20d89cc112bd6b.tar.gz |
tests: import: Factorize utility function.
* tests/pypi.scm (mock): Move this...
* guix/tests.scm: to here.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/tests.scm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/guix/tests.scm b/guix/tests.scm index 82ae7e2084..36341cb4cc 100644 --- a/guix/tests.scm +++ b/guix/tests.scm @@ -27,6 +27,7 @@ #:export (open-connection-for-tests random-text random-bytevector + mock with-derivation-narinfo dummy-package)) @@ -70,6 +71,16 @@ (loop (1+ i))) bv)))) +(define-syntax-rule (mock (module proc replacement) body ...) + "Within BODY, replace the definition of PROC from MODULE with the definition +given by REPLACEMENT." + (let* ((m (resolve-module 'module)) + (original (module-ref m 'proc))) + (dynamic-wind + (lambda () (module-set! m 'proc replacement)) + (lambda () body ...) + (lambda () (module-set! m 'proc original))))) + ;;; ;;; Narinfo files, as used by the substituter. |