Skip to content

Commit 7544034

Browse files
authored
toml, tests: update burntsushi > toml-lang and alexcrichton -> toml-rs (#26032)
1 parent f5013e5 commit 7544034

7 files changed

Lines changed: 45 additions & 45 deletions

File tree

‎.github/workflows/download_full_toml_test_suites.sh‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
set -ex
44

5-
rm -rf vlib/toml/tests/testdata/burntsushi vlib/toml/tests/testdata/iarna vlib/toml/tests/testdata/alexcrichton vlib/toml/tests/testdata/large_toml_file_test.toml
5+
rm -rf vlib/toml/tests/testdata/iarna vlib/toml/tests/testdata/toml_rs vlib/toml/tests/testdata/toml_lang vlib/toml/tests/testdata/large_toml_file_test.toml
66

77
./v retry -- ./v download -o vlib/toml/tests/testdata/large_toml_file_test.toml https://gist.githubusercontent.com/Larpon/89b0e3d94c6903851ff15559e5df7a05/raw/62a1f87a4e37bf157f2e0bfb32d85d840c98e422/large_toml_file_test.toml
88

99
./v retry -- git clone -n https://github.com/iarna/toml-spec-tests.git vlib/toml/tests/testdata/iarna
1010
git -C vlib/toml/tests/testdata/iarna checkout 1880b1a
1111

12-
./v retry -- git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/burntsushi
13-
git -C vlib/toml/tests/testdata/burntsushi checkout f30c716
12+
./v retry -- git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/toml_lang
13+
git -C vlib/toml/tests/testdata/toml_lang checkout f30c716
1414

15-
./v retry -- git clone -n https://github.com/toml-rs/toml.git vlib/toml/tests/testdata/alexcrichton
16-
git -C vlib/toml/tests/testdata/alexcrichton reset --hard 499e8c4
15+
./v retry -- git clone -n https://github.com/toml-rs/toml.git vlib/toml/tests/testdata/toml_rs
16+
git -C vlib/toml/tests/testdata/toml_rs reset --hard 499e8c4

‎vlib/toml/input/input.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn (c Config) read_input() !string {
2121
' ${typeof(c).name} should contain only one of the fields `file_path` OR `text` filled out')
2222
}
2323
if c.file_path == '' && c.text == '' {
24-
// TODO: passing both empty is used *a lot* by `./v vlib/toml/tests/burntsushi_toml_test.v`; investigate why.
24+
// TODO: passing both empty is used *a lot* by `./v vlib/toml/tests/toml_lang_test.v`; investigate why.
2525
return ''
2626
}
2727
if c.text != '' {

‎vlib/toml/parser/parser.v‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ pub fn (mut p Parser) root_table() ! {
499499
continue
500500
}
501501
// Check for "table injection":
502-
// https://github.com/BurntSushi/toml-test/blob/576db85/tests/invalid/table/injection-1.toml
503-
// https://github.com/BurntSushi/toml-test/blob/576db85/tests/invalid/table/injection-2.toml
502+
// https://github.com/toml-lang/toml-test/blob/576db85/tests/invalid/table/injection-1.toml
503+
// https://github.com/toml-lang/toml-test/blob/576db85/tests/invalid/table/injection-2.toml
504504
if p.build_abs_dotted_key(sub_table).starts_with(explicit_key) {
505505
return error(@MOD + '.' + @STRUCT + '.' + @FN +
506506
' key `${dotted_key}` has already been explicitly declared. Unexpected redeclaration at "${p.tok.kind}" "${p.tok.lit}" in this (excerpt): "...${p.excerpt()}..."')
@@ -933,7 +933,7 @@ pub fn (mut p Parser) double_array_of_tables(mut table map[string]ast.Value) ! {
933933
nm = &map[string]ast.Value{}
934934
// We register this implicit allocation as *explicit* to be able to catch
935935
// special cases like:
936-
// https://github.com/BurntSushi/toml-test/blob/576db852/tests/invalid/table/array-implicit.toml
936+
// https://github.com/toml-lang/toml-test/blob/576db852/tests/invalid/table/array-implicit.toml
937937
p.explicit_declared << first
938938
}
939939

‎vlib/toml/tests/iarna_toml_spec_test.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ fn to_iarna(value ast.Value, skip_value_map bool) string {
302302
}
303303
// NOTE test suite inconsistency.
304304
// It seems it's implementation specific how time and
305-
// date-time values are represented in detail. For now we follow the BurntSushi format
305+
// date-time values are represented in detail. For now we follow the toml-lang format
306306
// that expands to 6 digits which is also a valid RFC 3339 representation.
307307
json_text = to_iarna_time(json_text[1..json_text.len - 1])
308308
if skip_value_map {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
iarna/
2-
burntsushi/
3-
alexcrichton/
2+
toml_lang/
3+
toml_rs/
44
large_toml_file_test.toml
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Instructions for developers:
22
// The actual tests and data can be obtained by doing:
3-
// `git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/burntsushi`
4-
// `git -C vlib/toml/tests/testdata/burntsushi reset --hard f30c716
3+
// `git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/toml_lang`
4+
// `git -C vlib/toml/tests/testdata/toml_lang reset --hard f30c716
55
// See also the CI toml tests
66
import os
77
import toml
@@ -79,7 +79,7 @@ const valid_value_exceptions = [
7979
//'integer/long.toml', // TODO: https://github.com/vlang/v/issues/9507
8080

8181
const jq = os.find_abs_path_of_executable('jq') or { '' }
82-
const compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml_burntsushi')
82+
const compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml_toml_lang')
8383
// From: https://stackoverflow.com/a/38266731/1904615
8484
const jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
8585
def sorted_walk(f):
@@ -103,10 +103,10 @@ fn run(args []string) !string {
103103
return res.output
104104
}
105105

106-
// test_burnt_sushi_tomltest run though 'testdata/burntsushi/toml-test/*' if found.
107-
fn test_burnt_sushi_tomltest() {
106+
// test_toml_lang_tomltest run though 'testdata/toml_lang/toml-test/*' if found.
107+
fn test_toml_lang_tomltest() {
108108
eprintln('> running ${@LOCATION}')
109-
test_root := '${@VROOT}/vlib/toml/tests/testdata/burntsushi/tests'
109+
test_root := '${@VROOT}/vlib/toml/tests/testdata/toml_lang/tests'
110110
if !os.is_dir(test_root) {
111111
println('No test data directory found in "${test_root}"')
112112
assert true
@@ -186,7 +186,7 @@ fn test_burnt_sushi_tomltest() {
186186
bs_toml_json_path := os.join_path(compare_work_dir_root,
187187
os.file_name(valid_test_file).all_before_last('.') + '.json')
188188

189-
os.write_file(v_toml_json_path, to_burntsushi(toml_doc.ast.table))!
189+
os.write_file(v_toml_json_path, to_toml_lang(toml_doc.ast.table))!
190190

191191
bs_json := os.read_file(valid_test_file.all_before_last('.') + '.json')!
192192

@@ -256,8 +256,8 @@ fn test_burnt_sushi_tomltest() {
256256
}
257257
}
258258

259-
// to_burntsushi returns a BurntSushi compatible json string converted from the `value` ast.Value.
260-
fn to_burntsushi(value ast.Value) string {
259+
// to_toml_lang returns a toml-lang compatible json string converted from the `value` ast.Value.
260+
fn to_toml_lang(value ast.Value) string {
261261
match value {
262262
ast.Quoted {
263263
json_text := json2.Any(value.text).json_str()
@@ -323,7 +323,7 @@ fn to_burntsushi(value ast.Value) string {
323323
mut str := '{ '
324324
for key, val in value {
325325
json_key := json2.Any(key).json_str()
326-
str += ' ${json_key}: ${to_burntsushi(val)},'
326+
str += ' ${json_key}: ${to_toml_lang(val)},'
327327
}
328328
str = str.trim_right(',')
329329
str += ' }'
@@ -332,7 +332,7 @@ fn to_burntsushi(value ast.Value) string {
332332
[]ast.Value {
333333
mut str := '[ '
334334
for val in value {
335-
str += ' ${to_burntsushi(val)},'
335+
str += ' ${to_toml_lang(val)},'
336336
}
337337
str = str.trim_right(',')
338338
str += ' ]\n'

vlib/toml/tests/alexcrichton_toml_rs_test.v renamed to vlib/toml/tests/toml_rs_test.v

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const no_jq = os.getenv('VNO_JQ') == '1'
88

99
// Instructions for developers:
1010
// The actual tests and data can be obtained by doing:
11-
// `git clone -n https://github.com/toml-rs/toml.git vlib/toml/tests/testdata/alexcrichton`
12-
// `git -C vlib/toml/tests/testdata/alexcrichton reset --hard 499e8c4`
11+
// `git clone -n https://github.com/toml-rs/toml.git vlib/toml/tests/testdata/toml_rs`
12+
// `git -C vlib/toml/tests/testdata/toml_rs reset --hard 499e8c4`
1313
// See also the CI toml tests
1414
// Kept for easier handling of future updates to the tests
1515
const valid_exceptions = [
@@ -38,7 +38,7 @@ const use_type_2_arrays = [
3838
]
3939
const tests_folder = os.join_path('test-suite', 'tests')
4040
const jq = os.find_abs_path_of_executable('jq') or { '' }
41-
const compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml_alexcrichton')
41+
const compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml_toml_rs')
4242
// From: https://stackoverflow.com/a/38266731/1904615
4343
const jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
4444
def sorted_walk(f):
@@ -62,10 +62,10 @@ fn run(args []string) !string {
6262
return res.output
6363
}
6464

65-
// test_alexcrichton_toml_rs run though 'testdata/alexcrichton/toml-test/test-suite/tests/*' if found.
66-
fn test_alexcrichton_toml_rs() {
65+
// test_toml_rs_toml_rs run though 'testdata/toml_rs/toml-test/test-suite/tests/*' if found.
66+
fn test_toml_rs_toml_rs() {
6767
eprintln('> running ${@LOCATION}')
68-
test_root := '${@VROOT}/vlib/toml/tests/testdata/alexcrichton/test-suite/tests'
68+
test_root := '${@VROOT}/vlib/toml/tests/testdata/toml_rs/test-suite/tests'
6969
if os.is_dir(test_root) {
7070
valid_test_files := os.walk_ext(os.join_path(test_root, 'valid'), '.toml')
7171
invalid_test_files := os.walk_ext(os.join_path(test_root, 'invalid'), '.toml')
@@ -139,31 +139,31 @@ fn test_alexcrichton_toml_rs() {
139139

140140
v_toml_json_path := os.join_path(compare_work_dir_root,
141141
os.file_name(valid_test_file).all_before_last('.') + '.v.json')
142-
alexcrichton_toml_json_path := os.join_path(compare_work_dir_root,
142+
toml_rs_toml_json_path := os.join_path(compare_work_dir_root,
143143
os.file_name(valid_test_file).all_before_last('.') + '.json')
144144

145145
mut array_type := 1
146146
if relative in use_type_2_arrays {
147147
array_type = 2
148148
}
149149

150-
os.write_file(v_toml_json_path, to_alexcrichton(toml_doc.ast.table, array_type))!
150+
os.write_file(v_toml_json_path, to_toml_rs(toml_doc.ast.table, array_type))!
151151

152-
alexcrichton_json := os.read_file(valid_test_file.all_before_last('.') + '.json')!
152+
toml_rs_json := os.read_file(valid_test_file.all_before_last('.') + '.json')!
153153

154-
os.write_file(alexcrichton_toml_json_path, alexcrichton_json)!
154+
os.write_file(toml_rs_toml_json_path, toml_rs_json)!
155155

156156
v_normalized_json := run([jq, '-S', '-f "${jq_normalize_path}"', v_toml_json_path]) or {
157157
contents := os.read_file(v_toml_json_path)!
158158
panic(err.msg() + '\n${contents}')
159159
}
160-
alexcrichton_normalized_json := run([jq, '-S', '-f "${jq_normalize_path}"',
161-
alexcrichton_toml_json_path]) or {
160+
toml_rs_normalized_json := run([jq, '-S', '-f "${jq_normalize_path}"',
161+
toml_rs_toml_json_path]) or {
162162
contents := os.read_file(v_toml_json_path)!
163163
panic(err.msg() + '\n${contents}')
164164
}
165165

166-
assert alexcrichton_normalized_json == v_normalized_json
166+
assert toml_rs_normalized_json == v_normalized_json
167167

168168
valid++
169169
}
@@ -213,8 +213,8 @@ fn test_alexcrichton_toml_rs() {
213213
}
214214
}
215215

216-
// to_alexcrichton_time
217-
fn to_alexcrichton_time(time_str string) string {
216+
// to_toml_rs_time
217+
fn to_toml_rs_time(time_str string) string {
218218
if time_str.contains('.') {
219219
date_and_time := time_str.all_before('.')
220220
mut ms := time_str.all_after('.')
@@ -229,8 +229,8 @@ fn to_alexcrichton_time(time_str string) string {
229229
}
230230
}
231231

232-
// to_alexcrichton returns an alexcrichton compatible json string converted from the `value` ast.Value.
233-
fn to_alexcrichton(value ast.Value, array_type int) string {
232+
// to_toml_rs returns an toml_rs compatible json string converted from the `value` ast.Value.
233+
fn to_toml_rs(value ast.Value, array_type int) string {
234234
match value {
235235
ast.Quoted {
236236
json_text := json2.Any(value.text).json_str()
@@ -248,9 +248,9 @@ fn to_alexcrichton(value ast.Value, array_type int) string {
248248
}
249249
// NOTE test suite inconsistency.
250250
// It seems it's implementation specific how time and
251-
// date-time values are represented in detail. For now we follow the BurntSushi format
251+
// date-time values are represented in detail. For now we follow the toml-lang format
252252
// that expands to 6 digits which is also a valid RFC 3339 representation.
253-
json_text = to_alexcrichton_time(json_text[1..json_text.len - 1])
253+
json_text = to_toml_rs_time(json_text[1..json_text.len - 1])
254254
return '{ "type": "${typ}", "value": "${json_text}" }'
255255
}
256256
ast.Date {
@@ -259,7 +259,7 @@ fn to_alexcrichton(value ast.Value, array_type int) string {
259259
}
260260
ast.Time {
261261
mut json_text := json2.Any(value.text).json_str()
262-
json_text = to_alexcrichton_time(json_text[1..json_text.len - 1])
262+
json_text = to_toml_rs_time(json_text[1..json_text.len - 1])
263263
return '{ "type": "time", "value": "${json_text}" }'
264264
}
265265
ast.Bool {
@@ -295,7 +295,7 @@ fn to_alexcrichton(value ast.Value, array_type int) string {
295295
mut str := '{ '
296296
for key, val in value {
297297
json_key := json2.Any(key).json_str()
298-
str += ' ${json_key}: ${to_alexcrichton(val, array_type)},'
298+
str += ' ${json_key}: ${to_toml_rs(val, array_type)},'
299299
}
300300
str = str.trim_right(',')
301301
str += ' }'
@@ -309,7 +309,7 @@ fn to_alexcrichton(value ast.Value, array_type int) string {
309309
str = '[ '
310310
}
311311
for val in value {
312-
str += ' ${to_alexcrichton(val, array_type)},'
312+
str += ' ${to_toml_rs(val, array_type)},'
313313
}
314314
str = str.trim_right(',')
315315
if array_type == 1 {

0 commit comments

Comments
 (0)