Skip to content

Commit

Permalink
test: update all error grammar test suites
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Jul 8, 2024
1 parent 38cc9fc commit e452268
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 152 deletions.
12 changes: 6 additions & 6 deletions kclvm/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ install-rustc-wasm-wasi:
rustup target add wasm32-wasi

# Install python3 pytest
install-pytest:
python3 -mpip install --user -U pytest pytest-html pytest-xdist
install-test-deps:
python3 -mpip install --user -U pytest pytest-html pytest-xdist ruamel.yaml

# ------------------------
# Compile and run
Expand Down Expand Up @@ -82,19 +82,19 @@ codecov-lcov:
cargo llvm-cov --features llvm --lcov --output-path $(PWD)/.kclvm_cov/lcov.info -r --workspace --ignore-filename-regex gpyrpc.rs -- --nocapture

# Test runtime libaries using python functions
test-runtime: install-pytest
test-runtime: install-test-deps
cd ./tests/test_units && PYTHONPATH=./../../tests/test_units/runtime python3 -m pytest -vv || { echo 'kclvm/tests/test_units failed' ; exit 1; }

# E2E grammar tests.
test-grammar: install-pytest
test-grammar: install-test-deps
cd tests/integration/grammar && python3 -m pytest -v -n 5

# E2E grammar tests with the fast evaluator
test-grammar-evaluator: install-pytest
test-grammar-evaluator: install-test-deps
cd tests/integration/grammar && KCL_FAST_EVAL=1 python3 -m pytest -v -n 5

# E2E konfig tests.
test-konfig: install-pytest
test-konfig: install-test-deps
cd tests/integration/konfig && python3 -m pytest -v -n 5

# Parser fuzz.
Expand Down
2 changes: 1 addition & 1 deletion kclvm/tests/integration/grammar/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
TEST_PATH = "test/grammar"

# Ruamel YAML instance
ruamel_yaml = YAML(typ="unsafe", pure=True)
ruamel_yaml = YAML(pure=True)
# Convert None to null
ruamel_yaml.representer.add_representer(
type(None),
Expand Down
1 change: 1 addition & 0 deletions test/grammar/builtins/file/load_file_invalid/stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
failed to access the file 'not_exist.txt': No such file or directory
17 changes: 0 additions & 17 deletions test/grammar/builtins/file/load_file_invalid/stderr.golden.py

This file was deleted.

9 changes: 4 additions & 5 deletions test/grammar/builtins/json/output_2/main.k
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ _person = {
"key3": None
}
}
print("[", end="")
print(json.encode(_person, indent=4), end=",\n")
print(json.encode(_person, indent=4, ignore_private=True), end=",\n")
print(json.encode(_person, indent=4, ignore_none=True), end=",\n")
print(json.encode(_person, indent=4, ignore_private=True, ignore_none=True), end="]\n")
person0 = json.encode(_person, indent=4)
person1 = json.encode(_person, indent=4, ignore_private=True)
person2 = json.encode(_person, indent=4, ignore_none=True)
person3 = json.encode(_person, indent=4, ignore_private=True, ignore_none=True)
108 changes: 56 additions & 52 deletions test/grammar/builtins/json/output_2/stdout.golden
Original file line number Diff line number Diff line change
@@ -1,52 +1,56 @@
[{
"_key": "value",
"name": "Alice",
"age": 18,
"data": [
1,
2,
null
],
"labels": {
"key1": "value1",
"_key2": "value2",
"key3": null
}
},
{
"name": "Alice",
"age": 18,
"data": [
1,
2,
null
],
"labels": {
"key1": "value1",
"key3": null
}
},
{
"_key": "value",
"name": "Alice",
"age": 18,
"data": [
1,
2
],
"labels": {
"key1": "value1",
"_key2": "value2"
}
},
{
"name": "Alice",
"age": 18,
"data": [
1,
2
],
"labels": {
"key1": "value1"
}
}]
person0: |-
{
"_key": "value",
"name": "Alice",
"age": 18,
"data": [
1,
2,
null
],
"labels": {
"key1": "value1",
"_key2": "value2",
"key3": null
}
}
person1: |-
{
"name": "Alice",
"age": 18,
"data": [
1,
2,
null
],
"labels": {
"key1": "value1",
"key3": null
}
}
person2: |-
{
"_key": "value",
"name": "Alice",
"age": 18,
"data": [
1,
2
],
"labels": {
"key1": "value1",
"_key2": "value2"
}
}
person3: |-
{
"name": "Alice",
"age": 18,
"data": [
1,
2
],
"labels": {
"key1": "value1"
}
}
1 change: 1 addition & 0 deletions test/grammar/plugin/fail_0/stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
the plugin package `kcl_plugin.hello` is not found, please confirm if plugin mode is enabled
17 changes: 0 additions & 17 deletions test/grammar/plugin/fail_0/stderr.golden.py

This file was deleted.

1 change: 1 addition & 0 deletions test/grammar/plugin/fail_1/stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
the plugin package `kcl_plugin.hello` is not found, please confirm if plugin mode is enabled
17 changes: 0 additions & 17 deletions test/grammar/plugin/fail_1/stderr.golden.py

This file was deleted.

1 change: 1 addition & 0 deletions test/grammar/schema/union/fail/fail_2/stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cannot add member 'key' to schema 'Person'
19 changes: 0 additions & 19 deletions test/grammar/schema/union/fail/fail_2/stderr.golden.py

This file was deleted.

1 change: 1 addition & 0 deletions test/grammar/syntax/underline/stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name '__b' is not defined
18 changes: 0 additions & 18 deletions test/grammar/syntax/underline/stderr.golden.py

This file was deleted.

0 comments on commit e452268

Please sign in to comment.