Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytests/pattern_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ fi
TEST_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
REPO_DIR="$TEST_DIR/.."

pyang -p $OCDIR -p "$REPO_DIR/testdata" --plugindir "$REPO_DIR/pytests/plugins" --check-patterns "$REPO_DIR/testdata/regexp-test.yang"
pyang -p $OCDIR -p "$REPO_DIR/testdata" --msg-template="line {line}: {msg}" --plugindir "$REPO_DIR/pytests/plugins" --check-patterns "$REPO_DIR/testdata/regexp-test.yang"
10 changes: 5 additions & 5 deletions pytests/plugins/pattern_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def setup_ctx(self, ctx):
# Test case failure states.
error.add_error_code(
'VALID_PATTERN_DOES_NOT_MATCH', ErrorLevel.MAJOR,
'valid pattern "%s" does not match type "%s"')
'type "%s" rejected valid pattern: "%s"')
error.add_error_code(
'INVALID_PATTERN_MATCH', ErrorLevel.MAJOR,
'invalid pattern "%s" matches type "%s"')
'type "%s" accepted invalid pattern: "%s"')

# Error states.
error.add_error_code(
Expand Down Expand Up @@ -255,8 +255,8 @@ def check_patterns(ctx, mods):
break
else: # Exhausted all minterms.
err_add(ctx.errors, s.pos,
'VALID_PATTERN_DOES_NOT_MATCH', (s.arg,
typestmt.arg))
'VALID_PATTERN_DOES_NOT_MATCH', (typestmt.arg,
s.arg,))
elif is_statement_fail_testcase(s):
# Check that no minterm in the DNF is satisfied.
has_at_least_one_test = True
Expand All @@ -270,7 +270,7 @@ def check_patterns(ctx, mods):
minterm_matches = False
if minterm_matches:
err_add(ctx.errors, s.pos, 'INVALID_PATTERN_MATCH',
(s.arg, typestmt.arg))
(typestmt.arg, s.arg))
break

if not has_at_least_one_test:
Expand Down
26 changes: 13 additions & 13 deletions pytests/tests/golden.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
testdata/python-plugin-test.yang:20: error: invalid pattern "ipv4" matches type "string"
testdata/python-plugin-test.yang:21: error: valid pattern "ipv6" does not match type "string"
testdata/python-plugin-test.yang:20: error: type "string" accepted invalid pattern: "ipv4"
testdata/python-plugin-test.yang:21: error: type "string" rejected valid pattern: "ipv6"
testdata/python-plugin-test.yang:23: error: leaf "ipv4-2" does not have any test cases
testdata/python-plugin-test.yang:31: error: leaf "string" has unrestricted string type
testdata/python-plugin-test.yang:34: error: leaf "union" has unrestricted string type
testdata/python-plugin-test.yang:54: error: invalid pattern "ipv4" matches type "union"
testdata/python-plugin-test.yang:55: error: valid pattern "ipv5" does not match type "union"
testdata/python-plugin-test.yang:64: error: invalid pattern "ipv4" matches type "t:ip-string"
testdata/python-plugin-test.yang:65: error: valid pattern "ipv5" does not match type "t:ip-string"
testdata/python-plugin-test.yang:74: error: invalid pattern "ipv4" matches type "t:ip-string-typedef"
testdata/python-plugin-test.yang:75: error: valid pattern "ipv5" does not match type "t:ip-string-typedef"
testdata/python-plugin-test.yang:91: error: invalid pattern "ipv4" matches type "union"
testdata/python-plugin-test.yang:92: error: valid pattern "hehe" does not match type "union"
testdata/python-plugin-test.yang:93: error: invalid pattern "ipV5" matches type "union"
testdata/python-plugin-test.yang:94: error: invalid pattern "ipv6" matches type "union"
testdata/python-plugin-test.yang:104: error: valid pattern "ipv6" does not match type "t:ipv4-str"
testdata/python-plugin-test.yang:54: error: type "union" accepted invalid pattern: "ipv4"
testdata/python-plugin-test.yang:55: error: type "union" rejected valid pattern: "ipv5"
testdata/python-plugin-test.yang:64: error: type "t:ip-string" accepted invalid pattern: "ipv4"
testdata/python-plugin-test.yang:65: error: type "t:ip-string" rejected valid pattern: "ipv5"
testdata/python-plugin-test.yang:74: error: type "t:ip-string-typedef" accepted invalid pattern: "ipv4"
testdata/python-plugin-test.yang:75: error: type "t:ip-string-typedef" rejected valid pattern: "ipv5"
testdata/python-plugin-test.yang:91: error: type "union" accepted invalid pattern: "ipv4"
testdata/python-plugin-test.yang:92: error: type "union" rejected valid pattern: "hehe"
testdata/python-plugin-test.yang:93: error: type "union" accepted invalid pattern: "ipV5"
testdata/python-plugin-test.yang:94: error: type "union" accepted invalid pattern: "ipv6"
testdata/python-plugin-test.yang:104: error: type "t:ipv4-str" rejected valid pattern: "ipv6"