From c2e2aac0c9a0a5f19452781092e16169c0c9fade Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 11 Sep 2025 13:04:03 +0300 Subject: [PATCH] tests: use os.vtmp_dir() in autofree_toml.vv, so it can be cleaned up automatically; simplify the code --- vlib/v/gen/c/testdata/autofree_toml.vv | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/vlib/v/gen/c/testdata/autofree_toml.vv b/vlib/v/gen/c/testdata/autofree_toml.vv index 42272f8c0..c4c99cbfc 100644 --- a/vlib/v/gen/c/testdata/autofree_toml.vv +++ b/vlib/v/gen/c/testdata/autofree_toml.vv @@ -2,14 +2,8 @@ import toml import os -fn main() { - config_fname := 'config.toml' - tab_title := 'test tab title' - if !os.exists(config_fname) { - mut f := os.create(config_fname) or { panic(err) } - f.writeln('tab_title = "${tab_title}"') or { panic(err) } - f.close() - } - doc := toml.parse_file(config_fname) or { panic(err) } - assert doc.value('tab_title').string() == tab_title -} +config_fname := os.join_path(os.vtmp_dir(), 'config.toml') +tab_title := 'test tab title' +os.write_file(config_fname, 'tab_title = "${tab_title}"')! +doc := toml.parse_file(config_fname)! +assert doc.value('tab_title').string() == tab_title -- 2.39.5