kislyuk / yq

Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
https://kislyuk.github.io/yq/
Apache License 2.0
2.53k stars 81 forks source link

Failing test_yq_err #145

Closed susnux closed 2 years ago

susnux commented 2 years ago

Looks like the changed "expected message" from the test is not valid. When running on openSUSE I get an failure because of this change:

https://github.com/kislyuk/yq/commit/a5d2c572ee69009380a54a67662cf781f3036450#diff-ae070fbd66c55f7bf108994c0a42ffe69eee7319b5bf0f47bef0fcdbd8b496b3L65

[   16s] ======================================================================
[   16s] FAIL: test_yq_err (__main__.TestYq)
[   16s] ----------------------------------------------------------------------
[   16s] Traceback (most recent call last):
[   16s]   File "/home/abuild/rpmbuild/BUILD/yq-2.14.0/yq/__init__.py", line 245, in yq
[   16s]     load_yaml_docs(in_stream=input_stream, out_stream=jq.stdin, jq=jq, loader_class=loader_class,
[   16s]   File "/home/abuild/rpmbuild/BUILD/yq-2.14.0/yq/__init__.py", line 143, in load_yaml_docs
[   16s]     node = loader.get_node()
[   16s] yaml.scanner.ScannerError: while scanning for the next token
[   16s] found character '%' that cannot start any token
[   16s]   in "<file>", line 1, column 3
[   16s] 
[   16s] During handling of the above exception, another exception occurred:
[   16s] 
[   16s] Traceback (most recent call last):
[   16s]   File "/home/abuild/rpmbuild/BUILD/yq-2.14.0/test/test.py", line 53, in run_yq
[   16s]     cli(args, input_format=input_format)
[   16s]   File "/home/abuild/rpmbuild/BUILD/yq-2.14.0/yq/__init__.py", line 136, in cli
[   16s]     yq(**yq_args)
[   16s] SystemExit: yq: Error running jq: ScannerError: while scanning for the next token
[   16s] found character '%' that cannot start any token
[   16s]   in "<file>", line 1, column 3.
[   16s] 
[   16s] During handling of the above exception, another exception occurred:
[   16s] 
[   16s] Traceback (most recent call last):
[   16s]   File "/home/abuild/rpmbuild/BUILD/yq-2.14.0/test/test.py", line 80, in test_yq_err
[   16s]     self.run_yq("- %", ["."], expect_exit_codes={err, 2})
[   16s]   File "/home/abuild/rpmbuild/BUILD/yq-2.14.0/test/test.py", line 55, in run_yq
[   16s]     self.assertIn(e.code, expect_exit_codes)
[   16s] AssertionError: 'yq: Error running jq: ScannerError: while scanning for the next token\nfound character \'%\' that cannot start any token\n  in "<file>", line 1, column 3.' not found in {2, 'yq: Error running jq: ScannerError: while scanning for the next token\nfound character that cannot start any token\n  in "<file>", line 1, column 3.'}
[   16s] 
[   16s] ----------------------------------------------------------------------
[   16s] Ran 19 tests in 2.965s
[   16s] 
[   16s] FAILED (failures=1, expected failures=1)
kislyuk commented 2 years ago

Thanks, this should be fixed in e37a798.

susnux commented 2 years ago

This fixes the issue for me, but now your CI is failing. And I do not know how, because your CI and I use the same jq and pyyaml versions.

The scanner error comes from: https://github.com/yaml/pyyaml/blob/8cdff2c80573b8be8e8ad28929264a913a63aa33/lib/yaml/scanner.py#L258 So repr of "%" should be added which is '%' so not sure why this is not happening for the CI

kislyuk commented 2 years ago

Addressed in https://github.com/kislyuk/yq/commit/a7fe04ddf1c3f79b5551692ff99a5757b40011fa.