Megatest

run.scm at [b7a7d741be]
Login

File mtconfigf/tests/run.scm artifact f0fc4f2f77 part of check-in b7a7d741be


(load "../mtdebug/mtdebug.scm")
(import mtdebug)
(load "mtconfigf.scm")
(import (prefix mtconfigf config:))

(use mtdebug)
;; configure mtconfigf
(let* ((normal-fn debug:print)
       (info-fn   debug:print-info)
       (error-fn  debug:print-error)
       (default-port (current-output-port)))
  (config:set-debug-printers normal-fn info-fn error-fn default-port))


(use test)

(let* ((cfgdat
        (config:read-config "tests/test.config" #f #f)))

  
  (test #f "value" (config:lookup cfgdat "basic" "key"))
  (test #f 2 (config:lookup-number cfgdat "basic" "two"))
  
  )

(config:add-eval-string "(define (customfunc) \"hello\")")
(let* ((cfgdat
        (config:read-config "tests/test2.config" #f #f)))
  (test #f "bar" (config:lookup cfgdat "schemy" "rgetreftarget"))
  (test #f "baz" (config:lookup cfgdat "schemy" "rgetrefdefault"))
  (test #f "2" (config:lookup cfgdat "schemy" "addup"))
  (test #f 2 (config:lookup-number cfgdat "schemy" "addup"))
  (test #f "hello" (config:lookup cfgdat "schemy" "custom"))
  )

(test #f
      (conc "hello " (get-environment-variable "USER"))
      (config:eval-string-in-environment "hello $USER"))

(let* ((cfgdat
        (config:read-config "tests/test3.config" #f #t)))
  (test #f "hello" (config:lookup cfgdat "systemic" "hello"))
  (test #f
        (conc "hello " (get-environment-variable "USER"))
        (config:lookup cfgdat "systemic" "hellouser"))

  )