Megatest

Check-in [3decad145b]
Login
Overview
Comment:got configf testcase to show the problem
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65-try3
Files: files | file ages | folders
SHA1: 3decad145bdb968c13959f6f2d7e6b85ca2079b7
User & Date: matt on 2019-11-11 22:29:20
Other Links: branch diff | manifest | tags
Context
2019-11-11
22:40
Fixed Makefile in example check-in: c54ed87ce3 user: matt tags: v1.65-try3
22:29
got configf testcase to show the problem check-in: 3decad145b user: matt tags: v1.65-try3
2019-11-10
22:28
set debug printers for configf check-in: 2c1a4adb23 user: matt tags: v1.65-try3
Changes

Added configf-testing/Makefile version [4635f99b20].















>
>
>
>
>
>
>
1
2
3
4
5
6
7

%.o : %.scm
	csc -J -c $< -o $*.o

c : c.o a.o
	csc a.o c.o -o c

Added configf-testing/a.scm version [b6730203d0].













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(declare (unit a))

(module a
  *

  (import scheme chicken posix)
  
  (define (a:normalize-dir d)
    (if (and (file-exists? d)
	     (directory? d))
	(let ((curr (current-directory)))
	  (change-directory d)
	  (let ((nd (current-directory)))
	    (change-directory curr)
	    nd))
	d))

  )



	 

Modified configf-testing/c.scm from [4d512f0590] to [3ae900a3b5].



1
2
3
4
5

6
7
8

9
10
11
12


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32




33
34
35
36
37
38
39
40
41
42


;; pretend to be a config file processor
(use posix srfi-69)

;; (define getenv get-environment-variable)
(define (print-hash-table ht)

  (print "ht=" (hash-table->alist ht)))

(define cfgdata  (conc "(use simple-md5)"

		       "(set! getenv get-environment-variable)"
		       "(hash-table-set! ht \"PATH\" (getenv \"PATH\"))"
		       "(hash-table-set! ht \"currdir\" (current-directory))"
		       "(hash-table-set! ht \"md5sum\" (string->md5sum \"Hello\"))"))



(define (faux-cfg-processor ht cfgdata)
  (let* ((proc-str (conc "(lambda (ht)" cfgdata ")")))
    (with-input-from-string proc-str
      (lambda ()
	((eval (read)) ht)))))

(module cfgprocessor
	*

(import ports data-structures chicken scheme files srfi-69 posix srfi-1)
	
(define (faux-cfg-processor-modularized ht cfgdata)
  (let* ((proc-str (conc "(lambda (ht)" cfgdata ")")))
    (with-input-from-string proc-str
      (lambda ()
	((eval (read)) ht)))))
)

(import cfgprocessor)





(print "\nRun the non-modularized version")
(let ((ht (make-hash-table)))
  (faux-cfg-processor ht cfgdata)
  (print-hash-table ht))

(print "\nRun the modularized version")
(let ((ht (make-hash-table)))
  (faux-cfg-processor-modularized ht cfgdata)
  (print-hash-table ht))
>
>





>
|


>



|
>
>




















>
>
>
>










1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(declare (uses a))

;; pretend to be a config file processor
(use posix srfi-69)

;; (define getenv get-environment-variable)
(define (print-hash-table ht)
  (print "ht=")
  (pp (hash-table->alist ht)))

(define cfgdata  (conc "(use simple-md5)"
		       "(import a)"
		       "(set! getenv get-environment-variable)"
		       "(hash-table-set! ht \"PATH\" (getenv \"PATH\"))"
		       "(hash-table-set! ht \"currdir\" (current-directory))"
		       "(hash-table-set! ht \"md5sum\" (string->md5sum \"Hello\"))"
		       ;; in mtconfigf the below is not working
		       "(hash-table-set! ht \"var-tmp\" (a:normalize-dir \"/var/tmp\"))"))

(define (faux-cfg-processor ht cfgdata)
  (let* ((proc-str (conc "(lambda (ht)" cfgdata ")")))
    (with-input-from-string proc-str
      (lambda ()
	((eval (read)) ht)))))

(module cfgprocessor
	*

(import ports data-structures chicken scheme files srfi-69 posix srfi-1)
	
(define (faux-cfg-processor-modularized ht cfgdata)
  (let* ((proc-str (conc "(lambda (ht)" cfgdata ")")))
    (with-input-from-string proc-str
      (lambda ()
	((eval (read)) ht)))))
)

(import cfgprocessor)
(import a)

(print "\nCan I run stuff from module \"a\":")
(print (a:normalize-dir "/var/tmp"))

(print "\nRun the non-modularized version")
(let ((ht (make-hash-table)))
  (faux-cfg-processor ht cfgdata)
  (print-hash-table ht))

(print "\nRun the modularized version")
(let ((ht (make-hash-table)))
  (faux-cfg-processor-modularized ht cfgdata)
  (print-hash-table ht))