diff --git a/pytests/pattern_test.sh b/pytests/pattern_test.sh index 25ca3a7..69ec26f 100755 --- a/pytests/pattern_test.sh +++ b/pytests/pattern_test.sh @@ -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" diff --git a/pytests/plugins/pattern_test.py b/pytests/plugins/pattern_test.py index c9c7ee2..5cfc525 100644 --- a/pytests/plugins/pattern_test.py +++ b/pytests/plugins/pattern_test.py @@ -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( @@ -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 @@ -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: diff --git a/pytests/tests/golden.txt b/pytests/tests/golden.txt index 929f24a..27e9060 100644 --- a/pytests/tests/golden.txt +++ b/pytests/tests/golden.txt @@ -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"