mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
toml: update the alexcrichton and BurntSushi repos to their successors toml-rs, and toml-test, record new exceptions (#21152)
This commit is contained in:
parent
5da1fccaed
commit
ef48fb60c6
16
.github/workflows/download_full_toml_test_suites.sh
vendored
Executable file
16
.github/workflows/download_full_toml_test_suites.sh
vendored
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
.github/workflows/retry.sh wget https://gist.githubusercontent.com/Larpon/89b0e3d94c6903851ff15559e5df7a05/raw/62a1f87a4e37bf157f2e0bfb32d85d840c98e422/large_toml_file_test.toml -O vlib/toml/tests/testdata/large_toml_file_test.toml
|
||||||
|
|
||||||
|
.github/workflows/retry.sh git clone -n https://github.com/iarna/toml-spec-tests.git vlib/toml/tests/testdata/iarna
|
||||||
|
git -C vlib/toml/tests/testdata/iarna checkout 1880b1a
|
||||||
|
|
||||||
|
.github/workflows/retry.sh git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/burntsushi
|
||||||
|
git -C vlib/toml/tests/testdata/burntsushi checkout f30c716
|
||||||
|
|
||||||
|
.github/workflows/retry.sh git clone -n https://github.com/toml-rs/toml.git vlib/toml/tests/testdata/alexcrichton
|
||||||
|
git -C vlib/toml/tests/testdata/alexcrichton reset --hard 499e8c4
|
51
.github/workflows/toml_ci.yml
vendored
51
.github/workflows/toml_ci.yml
vendored
@ -13,61 +13,20 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
|
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
env:
|
|
||||||
TOML_BS_TESTS_PATH: vlib/toml/tests/testdata/burntsushi/toml-test
|
|
||||||
TOML_BS_TESTS_PINNED_COMMIT: 4634fdf
|
|
||||||
TOML_IARNA_TESTS_PATH: vlib/toml/tests/testdata/iarna/toml-test
|
|
||||||
TOML_IARNA_TESTS_PINNED_COMMIT: 1880b1a
|
|
||||||
TOML_AC_TESTS_PATH: vlib/toml/tests/testdata/alexcrichton/toml-test
|
|
||||||
TOML_AC_TESTS_PINNED_COMMIT: 499e8c4
|
|
||||||
VTEST_TOML_DO_LARGE_FILES: 1
|
|
||||||
VTEST_TOML_DO_YAML_CONVERSION: 1
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
.github/workflows/retry.sh sudo apt-get update
|
.github/workflows/retry.sh sudo apt-get update
|
||||||
.github/workflows/retry.sh sudo apt-get install --quiet -y jq libgc-dev
|
.github/workflows/retry.sh sudo apt-get install --quiet -y jq libgc-dev
|
||||||
- name: Build V
|
- name: Build V
|
||||||
run: make -j2 && ./v -cc gcc -o v cmd/v
|
run: make
|
||||||
|
|
||||||
- name: Show JQ Version
|
- name: Show JQ Version
|
||||||
run: jq --version
|
run: jq --version
|
||||||
|
|
||||||
- name: Run local TOML tests
|
- name: Download more TOML testsuits
|
||||||
run: ./v test vlib/toml
|
run: .github/workflows/download_full_toml_test_suites.sh
|
||||||
|
|
||||||
# Tests found at https://github.com/BurntSushi/toml-test
|
- name: Run TOML tests
|
||||||
- name: Clone BurntSushi/toml-test
|
run: VTEST_TOML_DO_YAML_CONVERSION=1 VTEST_TOML_DO_LARGE_FILES=1 ./v test vlib/toml
|
||||||
run: |
|
|
||||||
.github/workflows/retry.sh git clone -n https://github.com/BurntSushi/toml-test.git $TOML_BS_TESTS_PATH
|
|
||||||
.github/workflows/retry.sh git -C $TOML_BS_TESTS_PATH checkout $TOML_BS_TESTS_PINNED_COMMIT
|
|
||||||
|
|
||||||
- name: Run BurntSushi TOML tests
|
|
||||||
run: ./v vlib/toml/tests/burntsushi_toml_test.v
|
|
||||||
|
|
||||||
# Tests found at gist
|
|
||||||
- name: Get large_toml_file_test.toml
|
|
||||||
run: .github/workflows/retry.sh wget https://gist.githubusercontent.com/Larpon/89b0e3d94c6903851ff15559e5df7a05/raw/62a1f87a4e37bf157f2e0bfb32d85d840c98e422/large_toml_file_test.toml -O vlib/toml/tests/testdata/large_toml_file_test.toml
|
|
||||||
|
|
||||||
- name: Run large TOML file tests
|
|
||||||
run: ./v vlib/toml/tests/large_toml_file_test.v
|
|
||||||
|
|
||||||
# Tests found at https://github.com/iarna/toml-spec-tests
|
|
||||||
- name: Clone iarna/toml-spec-tests
|
|
||||||
run: |
|
|
||||||
.github/workflows/retry.sh git clone -n https://github.com/iarna/toml-spec-tests.git $TOML_IARNA_TESTS_PATH
|
|
||||||
git -C $TOML_IARNA_TESTS_PATH checkout $TOML_IARNA_TESTS_PINNED_COMMIT
|
|
||||||
|
|
||||||
- name: Run iarna TOML tests
|
|
||||||
run: ./v -gc boehm vlib/toml/tests/iarna_toml_spec_test.v
|
|
||||||
|
|
||||||
# Tests found at https://github.com/alexcrichton/toml-rs
|
|
||||||
- name: Clone alexcrichton/toml-rs
|
|
||||||
run: |
|
|
||||||
.github/workflows/retry.sh git clone -n https://github.com/alexcrichton/toml-rs.git $TOML_AC_TESTS_PATH
|
|
||||||
git -C $TOML_AC_TESTS_PATH checkout $TOML_AC_TESTS_PINNED_COMMIT
|
|
||||||
|
|
||||||
- name: Run alexcrichton TOML tests
|
|
||||||
run: ./v vlib/toml/tests/alexcrichton_toml_rs_test.v
|
|
||||||
|
@ -4,10 +4,12 @@ import toml.ast
|
|||||||
import x.json2
|
import x.json2
|
||||||
|
|
||||||
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
||||||
|
const no_jq = os.getenv('VNO_JQ') == '1'
|
||||||
|
|
||||||
// Instructions for developers:
|
// Instructions for developers:
|
||||||
// The actual tests and data can be obtained by doing:
|
// The actual tests and data can be obtained by doing:
|
||||||
// `git clone --depth 1 https://github.com/alexcrichton/toml-rs.git vlib/toml/tests/testdata/alexcrichton/toml-test`
|
// `git clone -n https://github.com/toml-rs/toml.git vlib/toml/tests/testdata/alexcrichton`
|
||||||
|
// `git -C vlib/toml/tests/testdata/alexcrichton reset --hard 499e8c4`
|
||||||
// See also the CI toml tests
|
// See also the CI toml tests
|
||||||
// Kept for easier handling of future updates to the tests
|
// Kept for easier handling of future updates to the tests
|
||||||
const valid_exceptions = [
|
const valid_exceptions = [
|
||||||
@ -62,11 +64,11 @@ fn run(args []string) !string {
|
|||||||
|
|
||||||
// test_alexcrichton_toml_rs run though 'testdata/alexcrichton/toml-test/test-suite/tests/*' if found.
|
// test_alexcrichton_toml_rs run though 'testdata/alexcrichton/toml-test/test-suite/tests/*' if found.
|
||||||
fn test_alexcrichton_toml_rs() {
|
fn test_alexcrichton_toml_rs() {
|
||||||
this_file := @FILE
|
eprintln('> running ${@LOCATION}')
|
||||||
test_root := os.join_path(os.dir(this_file), 'testdata', 'alexcrichton', 'toml-test')
|
test_root := '${@VROOT}/vlib/toml/tests/testdata/alexcrichton/test-suite/tests'
|
||||||
if os.is_dir(test_root) {
|
if os.is_dir(test_root) {
|
||||||
valid_test_files := os.walk_ext(os.join_path(test_root, 'test-suite', 'tests',
|
valid_test_files := os.walk_ext(os.join_path(test_root, 'valid'), '.toml')
|
||||||
'valid'), '.toml')
|
invalid_test_files := os.walk_ext(os.join_path(test_root, 'invalid'), '.toml')
|
||||||
println('Testing ${valid_test_files.len} valid TOML files...')
|
println('Testing ${valid_test_files.len} valid TOML files...')
|
||||||
mut valid := 0
|
mut valid := 0
|
||||||
mut e := 0
|
mut e := 0
|
||||||
@ -94,7 +96,7 @@ fn test_alexcrichton_toml_rs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the command-line tool `jq` is installed, value tests can be run as well.
|
// If the command-line tool `jq` is installed, value tests can be run as well.
|
||||||
if jq != '' {
|
if jq != '' && !no_jq {
|
||||||
println('Testing value output of ${valid_test_files.len} valid TOML files using "${jq}"...')
|
println('Testing value output of ${valid_test_files.len} valid TOML files using "${jq}"...')
|
||||||
|
|
||||||
if os.exists(compare_work_dir_root) {
|
if os.exists(compare_work_dir_root) {
|
||||||
@ -171,8 +173,6 @@ fn test_alexcrichton_toml_rs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
invalid_test_files := os.walk_ext(os.join_path(test_root, 'test-suite', 'tests',
|
|
||||||
'invalid'), '.toml')
|
|
||||||
println('Testing ${invalid_test_files.len} invalid TOML files...')
|
println('Testing ${invalid_test_files.len} invalid TOML files...')
|
||||||
mut invalid := 0
|
mut invalid := 0
|
||||||
e = 0
|
e = 0
|
||||||
|
@ -1,29 +1,83 @@
|
|||||||
// vtest flaky: true
|
// vtest flaky: true
|
||||||
// vtest retry: 3
|
// vtest retry: 3
|
||||||
|
|
||||||
|
// Instructions for developers:
|
||||||
|
// The actual tests and data can be obtained by doing:
|
||||||
|
// `git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/burntsushi`
|
||||||
|
// `git -C vlib/toml/tests/testdata/burntsushi reset --hard f30c716
|
||||||
|
// See also the CI toml tests
|
||||||
import os
|
import os
|
||||||
import toml
|
import toml
|
||||||
import toml.ast
|
import toml.ast
|
||||||
import x.json2
|
import x.json2
|
||||||
|
|
||||||
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
||||||
|
const no_jq = os.getenv('VNO_JQ') == '1'
|
||||||
|
|
||||||
// Instructions for developers:
|
|
||||||
// The actual tests and data can be obtained by doing:
|
|
||||||
// `cd vlib/toml/tests/testdata`
|
|
||||||
// `git clone --depth 1 https://github.com/BurntSushi/toml-test.git burntsushi/toml-test`
|
|
||||||
// See also the CI toml tests
|
|
||||||
// Kept for easier handling of future updates to the tests
|
// Kept for easier handling of future updates to the tests
|
||||||
const valid_exceptions = [
|
const valid_exceptions = [
|
||||||
|
'array/open-parent-table.toml',
|
||||||
|
'comment/after-literal-no-ws.toml',
|
||||||
'comment/everywhere.toml',
|
'comment/everywhere.toml',
|
||||||
|
'datetime/no-seconds.toml',
|
||||||
|
'inline-table/newline.toml',
|
||||||
|
'key/space.toml',
|
||||||
|
'key/start.toml',
|
||||||
|
'key/unicode.toml',
|
||||||
|
'string/escapes.toml',
|
||||||
|
'string/escape-esc.toml',
|
||||||
|
'string/hex-escape.toml',
|
||||||
|
'string/multiline-escaped-crlf.toml',
|
||||||
|
'string/multiline-quotes.toml',
|
||||||
|
'table/array-implicit-and-explicit-after.toml',
|
||||||
|
'table/array-within-dotted.toml',
|
||||||
|
]
|
||||||
|
const jq_not_equal = [
|
||||||
|
'do_not_remove',
|
||||||
|
'datetime/milliseconds.toml',
|
||||||
|
'float/zero.toml',
|
||||||
|
'inline-table/spaces.toml',
|
||||||
|
'spec/array-of-tables-1.toml',
|
||||||
|
'spec/float-0.toml',
|
||||||
|
'spec/float-2.toml',
|
||||||
]
|
]
|
||||||
const invalid_exceptions = [
|
const invalid_exceptions = [
|
||||||
|
'array/only-comma-1.toml',
|
||||||
|
'control/bare-cr.toml',
|
||||||
'datetime/hour-over.toml',
|
'datetime/hour-over.toml',
|
||||||
'datetime/mday-under.toml',
|
'datetime/mday-under.toml',
|
||||||
'datetime/minute-over.toml',
|
'datetime/minute-over.toml',
|
||||||
'datetime/month-under.toml',
|
'datetime/month-under.toml',
|
||||||
'datetime/second-over.toml',
|
'datetime/second-over.toml',
|
||||||
|
'datetime/feb-29.toml',
|
||||||
|
'datetime/feb-30.toml',
|
||||||
|
'inline-table/duplicate-key-2.toml',
|
||||||
|
'inline-table/duplicate-key-3.toml',
|
||||||
|
'inline-table/overwrite-2.toml',
|
||||||
|
'inline-table/overwrite-4.toml',
|
||||||
|
'inline-table/overwrite-5.toml',
|
||||||
|
'inline-table/overwrite-8.toml',
|
||||||
|
'local-date/feb-29.toml',
|
||||||
|
'local-date/feb-30.toml',
|
||||||
|
'local-date/mday-under.toml',
|
||||||
|
'local-date/month-under.toml',
|
||||||
|
'local-datetime/feb-29.toml',
|
||||||
|
'local-datetime/feb-30.toml',
|
||||||
|
'local-datetime/hour-over.toml',
|
||||||
|
'local-datetime/mday-under.toml',
|
||||||
|
'local-datetime/minute-over.toml',
|
||||||
|
'local-datetime/month-under.toml',
|
||||||
|
'local-datetime/second-over.toml',
|
||||||
|
'local-time/hour-over.toml',
|
||||||
|
'local-time/minute-over.toml',
|
||||||
|
'local-time/second-over.toml',
|
||||||
|
'string/multiline-escape-space-2.toml',
|
||||||
|
'table/duplicate-key-dotted-array.toml',
|
||||||
|
'table/redefine-2.toml',
|
||||||
|
]
|
||||||
|
const valid_value_exceptions = [
|
||||||
|
'do_not_remove',
|
||||||
]
|
]
|
||||||
const valid_value_exceptions = []string{}
|
|
||||||
// BUG with string interpolation of '${i64(-9223372036854775808)}') see below for workaround
|
// BUG with string interpolation of '${i64(-9223372036854775808)}') see below for workaround
|
||||||
//'integer/long.toml', // TODO: https://github.com/vlang/v/issues/9507
|
//'integer/long.toml', // TODO: https://github.com/vlang/v/issues/9507
|
||||||
|
|
||||||
@ -54,36 +108,40 @@ fn run(args []string) !string {
|
|||||||
|
|
||||||
// test_burnt_sushi_tomltest run though 'testdata/burntsushi/toml-test/*' if found.
|
// test_burnt_sushi_tomltest run though 'testdata/burntsushi/toml-test/*' if found.
|
||||||
fn test_burnt_sushi_tomltest() {
|
fn test_burnt_sushi_tomltest() {
|
||||||
this_file := @FILE
|
eprintln('> running ${@LOCATION}')
|
||||||
test_root := os.join_path(os.dir(this_file), 'testdata', 'burntsushi', 'toml-test',
|
test_root := '${@VROOT}/vlib/toml/tests/testdata/burntsushi/tests'
|
||||||
'tests')
|
|
||||||
if !os.is_dir(test_root) {
|
if !os.is_dir(test_root) {
|
||||||
println('No test data directory found in "${test_root}"')
|
println('No test data directory found in "${test_root}"')
|
||||||
assert true
|
assert true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
valid_folder := os.join_path('toml-test', 'tests', 'valid')
|
valid_folder := 'valid'
|
||||||
invalid_folder := os.join_path('toml-test', 'tests', 'invalid')
|
valid_test_files := os.walk_ext('${test_root}/valid', '.toml').map(it.replace('\\',
|
||||||
valid_test_files := os.walk_ext(os.join_path(test_root, 'valid'), '.toml')
|
'/')).sorted()
|
||||||
println('Testing ${valid_test_files.len} valid TOML files...')
|
invalid_folder := 'invalid'
|
||||||
|
invalid_test_files := os.walk_ext('${test_root}/invalid', '.toml').map(it.replace('\\',
|
||||||
|
'/')).sorted()
|
||||||
|
//
|
||||||
|
println('\nTesting ${valid_test_files.len} valid TOML files...')
|
||||||
mut valid := 0
|
mut valid := 0
|
||||||
mut e := 0
|
mut e := 0
|
||||||
for i, valid_test_file in valid_test_files {
|
for i, valid_test_file in valid_test_files {
|
||||||
mut relative := valid_test_file.all_after(valid_folder).trim_left(os.path_separator)
|
relative := valid_test_file.all_after(valid_folder).trim_left('/')
|
||||||
$if windows {
|
|
||||||
relative = relative.replace('/', '\\')
|
|
||||||
}
|
|
||||||
if relative in valid_exceptions {
|
if relative in valid_exceptions {
|
||||||
e++
|
e++
|
||||||
idx := valid_exceptions.index(relative) + 1
|
idx := valid_exceptions.index(relative) + 1
|
||||||
println('SKIP [${i + 1}/${valid_test_files.len}] "${valid_test_file}" VALID EXCEPTION [${idx}/${valid_exceptions.len}]...')
|
println('SKIP [${i + 1}/${valid_test_files.len}] "${valid_test_file}" VALID EXCEPTION [${idx}/${valid_exceptions.len}]...')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// eprintln('>>> trying to parse: ${valid_test_file} | relative: $relative')
|
||||||
|
toml_doc := toml.parse_file(valid_test_file) or {
|
||||||
|
eprintln('>>> error while parsing: ${valid_test_file}')
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
valid++
|
||||||
if !hide_oks {
|
if !hide_oks {
|
||||||
println('OK [${i + 1}/${valid_test_files.len}] "${valid_test_file}"...')
|
println('OK [${i + 1}/${valid_test_files.len}] "${valid_test_file}"...')
|
||||||
}
|
}
|
||||||
toml_doc := toml.parse_file(valid_test_file)!
|
|
||||||
valid++
|
|
||||||
}
|
}
|
||||||
println('${valid}/${valid_test_files.len} TOML files were parsed correctly')
|
println('${valid}/${valid_test_files.len} TOML files were parsed correctly')
|
||||||
if valid_exceptions.len > 0 {
|
if valid_exceptions.len > 0 {
|
||||||
@ -91,8 +149,8 @@ fn test_burnt_sushi_tomltest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the command-line tool `jq` is installed, value tests can be run as well.
|
// If the command-line tool `jq` is installed, value tests can be run as well.
|
||||||
if jq != '' {
|
if jq != '' && !no_jq {
|
||||||
println('Testing value output of ${valid_test_files.len} valid TOML files using "${jq}"...')
|
println('\nTesting value output of ${valid_test_files.len} valid TOML files using "${jq}"...')
|
||||||
|
|
||||||
if os.exists(compare_work_dir_root) {
|
if os.exists(compare_work_dir_root) {
|
||||||
os.rmdir_all(compare_work_dir_root)!
|
os.rmdir_all(compare_work_dir_root)!
|
||||||
@ -105,10 +163,7 @@ fn test_burnt_sushi_tomltest() {
|
|||||||
valid = 0
|
valid = 0
|
||||||
e = 0
|
e = 0
|
||||||
for i, valid_test_file in valid_test_files {
|
for i, valid_test_file in valid_test_files {
|
||||||
mut relative := valid_test_file.all_after(valid_folder).trim_left(os.path_separator)
|
relative := valid_test_file.all_after(valid_folder).trim_left('/')
|
||||||
$if windows {
|
|
||||||
relative = relative.replace('/', '\\')
|
|
||||||
}
|
|
||||||
// Skip the file if we know it can't be parsed or we know that the value retrieval needs work.
|
// Skip the file if we know it can't be parsed or we know that the value retrieval needs work.
|
||||||
if relative in valid_exceptions {
|
if relative in valid_exceptions {
|
||||||
e++
|
e++
|
||||||
@ -127,6 +182,7 @@ fn test_burnt_sushi_tomltest() {
|
|||||||
println('OK [${i + 1}/${valid_test_files.len}] "${valid_test_file}"...')
|
println('OK [${i + 1}/${valid_test_files.len}] "${valid_test_file}"...')
|
||||||
}
|
}
|
||||||
toml_doc := toml.parse_file(valid_test_file)!
|
toml_doc := toml.parse_file(valid_test_file)!
|
||||||
|
// eprintln(' relative: $relative parsed')
|
||||||
|
|
||||||
v_toml_json_path := os.join_path(compare_work_dir_root,
|
v_toml_json_path := os.join_path(compare_work_dir_root,
|
||||||
os.file_name(valid_test_file).all_before_last('.') + '.v.json')
|
os.file_name(valid_test_file).all_before_last('.') + '.v.json')
|
||||||
@ -148,25 +204,34 @@ fn test_burnt_sushi_tomltest() {
|
|||||||
panic(err.msg() + '\n${contents}')
|
panic(err.msg() + '\n${contents}')
|
||||||
}
|
}
|
||||||
|
|
||||||
assert bs_normalized_json == v_normalized_json
|
if relative in jq_not_equal {
|
||||||
|
e++
|
||||||
|
eprintln('>>> skipped: relative: ${relative} in jq_not_equal, bs_normalized_json != bs_normalized_json')
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if bs_normalized_json != v_normalized_json {
|
||||||
|
e++
|
||||||
|
eprintln('>>> error: relative: ${relative}, bs_normalized_json != bs_normalized_json')
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
assert bs_normalized_json == v_normalized_json
|
||||||
valid++
|
valid++
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
println('> Skipping json conversion tests, since jq: ${jq} | no_jq: ${no_jq}')
|
||||||
}
|
}
|
||||||
println('${valid}/${valid_test_files.len} TOML files were parsed correctly and value checked')
|
println('${valid}/${valid_test_files.len} TOML files were parsed correctly and value checked')
|
||||||
if valid_value_exceptions.len > 0 {
|
if valid_value_exceptions.len > 0 {
|
||||||
println('TODO Skipped value checks of ${valid_value_exceptions.len} valid TOML files...')
|
println('TODO Skipped value checks of ${valid_value_exceptions.len} valid TOML files...')
|
||||||
}
|
}
|
||||||
|
|
||||||
invalid_test_files := os.walk_ext(os.join_path(test_root, 'invalid'), '.toml')
|
println('\nTesting ${invalid_test_files.len} invalid TOML files...')
|
||||||
println('Testing ${invalid_test_files.len} invalid TOML files...')
|
|
||||||
mut invalid := 0
|
mut invalid := 0
|
||||||
e = 0
|
e = 0
|
||||||
for i, invalid_test_file in invalid_test_files {
|
for i, invalid_test_file in invalid_test_files {
|
||||||
mut relative := invalid_test_file.all_after(invalid_folder).trim_left(os.path_separator)
|
relative := invalid_test_file.all_after(invalid_folder).trim_left('/')
|
||||||
$if windows {
|
|
||||||
relative = relative.replace('/', '\\')
|
|
||||||
}
|
|
||||||
if relative in invalid_exceptions {
|
if relative in invalid_exceptions {
|
||||||
e++
|
e++
|
||||||
idx := invalid_exceptions.index(relative) + 1
|
idx := invalid_exceptions.index(relative) + 1
|
||||||
@ -178,7 +243,7 @@ fn test_burnt_sushi_tomltest() {
|
|||||||
}
|
}
|
||||||
if toml_doc := toml.parse_file(invalid_test_file) {
|
if toml_doc := toml.parse_file(invalid_test_file) {
|
||||||
content_that_should_have_failed := os.read_file(invalid_test_file)!
|
content_that_should_have_failed := os.read_file(invalid_test_file)!
|
||||||
println(' This TOML should have failed:\n${'-'.repeat(40)}\n${content_that_should_have_failed}\n${'-'.repeat(40)}')
|
println(' This TOML from relative: ${relative}, invalid_test_file: ${invalid_test_file}, should have failed:\n${'-'.repeat(100)}\n${content_that_should_have_failed}\n${'-'.repeat(100)}')
|
||||||
assert false
|
assert false
|
||||||
} else {
|
} else {
|
||||||
if !hide_oks {
|
if !hide_oks {
|
||||||
@ -188,7 +253,7 @@ fn test_burnt_sushi_tomltest() {
|
|||||||
}
|
}
|
||||||
invalid++
|
invalid++
|
||||||
}
|
}
|
||||||
println('${invalid}/${invalid_test_files.len} TOML files were parsed correctly')
|
println('${invalid}/${invalid_test_files.len} invalid TOML files correctly had parsing errors')
|
||||||
if invalid_exceptions.len > 0 {
|
if invalid_exceptions.len > 0 {
|
||||||
println('TODO Skipped parsing of ${invalid_exceptions.len} invalid TOML files...')
|
println('TODO Skipped parsing of ${invalid_exceptions.len} invalid TOML files...')
|
||||||
}
|
}
|
||||||
|
@ -69,14 +69,14 @@ fn run(args []string) !string {
|
|||||||
// test_iarna_toml_spec_tests run though 'testdata/iarna/toml-test/*' if found.
|
// test_iarna_toml_spec_tests run though 'testdata/iarna/toml-test/*' if found.
|
||||||
fn test_iarna_toml_spec_tests() {
|
fn test_iarna_toml_spec_tests() {
|
||||||
this_file := @FILE
|
this_file := @FILE
|
||||||
test_root := os.join_path(os.dir(this_file), 'testdata', 'iarna', 'toml-test')
|
test_root := os.join_path(os.dir(this_file), 'testdata', 'iarna')
|
||||||
if os.is_dir(test_root) {
|
if os.is_dir(test_root) {
|
||||||
valid_test_files := os.walk_ext(os.join_path(test_root, 'values'), '.toml')
|
valid_test_files := os.walk_ext(os.join_path(test_root, 'values'), '.toml')
|
||||||
println('Testing ${valid_test_files.len} valid TOML files...')
|
println('Testing ${valid_test_files.len} valid TOML files...')
|
||||||
mut valid := 0
|
mut valid := 0
|
||||||
mut e := 0
|
mut e := 0
|
||||||
for i, valid_test_file in valid_test_files {
|
for i, valid_test_file in valid_test_files {
|
||||||
mut relative := valid_test_file.all_after('toml-test').trim_left(os.path_separator)
|
mut relative := valid_test_file.all_after('iarna').trim_left(os.path_separator)
|
||||||
$if windows {
|
$if windows {
|
||||||
relative = relative.replace('/', '\\')
|
relative = relative.replace('/', '\\')
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ fn test_iarna_toml_spec_tests() {
|
|||||||
valid = 0
|
valid = 0
|
||||||
e = 0
|
e = 0
|
||||||
for i, valid_test_file in valid_test_files {
|
for i, valid_test_file in valid_test_files {
|
||||||
mut relative := valid_test_file.all_after('toml-test').trim_left(os.path_separator)
|
mut relative := valid_test_file.all_after('iarna').trim_left(os.path_separator)
|
||||||
$if windows {
|
$if windows {
|
||||||
relative = relative.replace('/', '\\')
|
relative = relative.replace('/', '\\')
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ fn test_iarna_toml_spec_tests() {
|
|||||||
mut invalid := 0
|
mut invalid := 0
|
||||||
e = 0
|
e = 0
|
||||||
for i, invalid_test_file in invalid_test_files {
|
for i, invalid_test_file in invalid_test_files {
|
||||||
mut relative := invalid_test_file.all_after('toml-test').trim_left(os.path_separator)
|
mut relative := invalid_test_file.all_after('iarna').trim_left(os.path_separator)
|
||||||
$if windows {
|
$if windows {
|
||||||
relative = relative.replace('/', '\\')
|
relative = relative.replace('/', '\\')
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,17 @@ import toml
|
|||||||
|
|
||||||
// Instructions for developers:
|
// Instructions for developers:
|
||||||
// The large (1MB) TOML file can be obtained by doing:
|
// The large (1MB) TOML file can be obtained by doing:
|
||||||
// `cd vlib/toml/tests/testdata`
|
|
||||||
// `wget https://gist.githubusercontent.com/Larpon/89b0e3d94c6903851ff15559e5df7a05/raw/62a1f87a4e37bf157f2e0bfb32d85d840c98e422/large_toml_file_test.toml`
|
// `wget https://gist.githubusercontent.com/Larpon/89b0e3d94c6903851ff15559e5df7a05/raw/62a1f87a4e37bf157f2e0bfb32d85d840c98e422/large_toml_file_test.toml`
|
||||||
|
// `mv large_toml_file_test.toml vlib/toml/tests/testdata/`
|
||||||
|
|
||||||
// See also the CI toml tests
|
const toml_file = os.join_path_single(@VEXEROOT, 'vlib/toml/tests/testdata/large_toml_file_test.toml')
|
||||||
|
|
||||||
// test_large_file parser 'testdata/large_toml_file_test.toml' if found.
|
|
||||||
fn test_large_file() {
|
fn test_large_file() {
|
||||||
toml_file :=
|
if !os.exists(toml_file) {
|
||||||
os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
|
eprintln('skipping ${@FILE} since ${toml_file} is missing.')
|
||||||
'.toml'
|
return
|
||||||
if os.exists(toml_file) {
|
}
|
||||||
println('Testing parsing of large (${os.file_size(toml_file)} bytes) "${toml_file}"...')
|
println('Testing parsing of large (${os.file_size(toml_file)} bytes) "${toml_file}"...')
|
||||||
toml_doc := toml.parse_file(toml_file) or { panic(err) }
|
doc := toml.parse_file(toml_file) or { panic(err) }
|
||||||
println('OK [1/1] "${toml_file}"...') // So it can be checked with `v -stats test ...`
|
assert true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
6
vlib/toml/tests/testdata/.gitignore
vendored
6
vlib/toml/tests/testdata/.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
iarna/toml-test/
|
iarna/
|
||||||
burntsushi/toml-test/
|
burntsushi/
|
||||||
alexcrichton/toml-test/
|
alexcrichton/
|
||||||
large_toml_file_test.toml
|
large_toml_file_test.toml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user