Skip to content

Commit e40c2e5

Browse files
rootroot
authored andcommitted
[0039] 修复 config-read-file 测试:使用静态数据文件替代 /tmp 临时文件
1 parent 64d4c3c commit e40c2e5

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

tests/liii/config-parser/config-read-file-test.scm

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(liii config-parser)
33
(liii raw-string)
44
(scheme base)
5-
(scheme file)
65
) ;import
76

87
(check-set-mode! 'report-failed)
@@ -31,18 +30,11 @@
3130
;; 文件内容解析规则与 `config-read-string` 一致。
3231
;; 支持注释、多分隔符、DEFAULT section 继承等。
3332

34-
;; 使用临时文件测试 config-read-file
35-
(let ((tmpfile "/tmp/test-config-parser.ini"))
36-
(let ((port (open-output-file tmpfile)))
37-
(display "[database]\nhost=localhost\nport=5432\n" port)
38-
(close-output-port port)
39-
) ;let
40-
(let ((config (make-config-parser)))
41-
(config-read-file config tmpfile)
42-
(check (config-sections config) => '("database"))
43-
(check (config-get config "database" "host") => "localhost")
44-
(check (config-get config "database" "port") => "5432")
45-
) ;let
33+
(let ((config (make-config-parser)))
34+
(config-read-file config "tests/liii/config-parser/test-data.ini")
35+
(check (config-sections config) => '("database"))
36+
(check (config-get config "database" "host") => "localhost")
37+
(check (config-get config "database" "port") => "5432")
4638
) ;let
4739

4840
(check-report)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[database]
2+
host=localhost
3+
port=5432

0 commit comments

Comments
 (0)