Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua output fixes #1811

Merged
merged 3 commits into from
Oct 12, 2023
Merged

Lua output fixes #1811

merged 3 commits into from
Oct 12, 2023

Conversation

Zash
Copy link
Contributor

@Zash Zash commented Oct 4, 2023

Fixes for some quirks noticed while working on #1810

  • +.inf was not handled
  • yq -o lua .foo <<< '{"foo":{"bar":1}} or the --prettyPrint flag would output {bar=1} only, without the pre- & suffix.
  • Handle empty Tag field, if the parser side does not set it (I did before finding a good way to distinguish integer and float in the Lua parser)

Could split into multiple PRs if that is desirable.

@mikefarah
Copy link
Owner

Is it possible to add a test to show the prettyPrint fix? If it can't be done in lua_test.go you could always add it in as an acceptance tests shell file (under output_format.sh will probably do).

@Zash
Copy link
Contributor Author

Zash commented Oct 6, 2023

Will try.

It seems certain operations like --prettyPrint or subset selections does
not produce a DocumentNode, which is where the lua pre- and suffix was
printed, causing those to be omitted.
Using the method call seems more reliable in case the input parser
forgets to set the tag.
@Zash
Copy link
Contributor Author

Zash commented Oct 10, 2023

Before

...
testLuaOutputPretty
ASSERT:expected:<return {
	["animals"] = {
		["cat"] = "meow";
	};
};> but was:<{
	["animals"] = {
		["cat"] = "meow";
	};
}>
shunit2:ERROR testLuaOutputPretty() returned non-zero return code.
testLuaOutputSubset
ASSERT:expected:<return {
	["cat"] = "meow";
};> but was:<{
	["cat"] = "meow";
}>
shunit2:ERROR testLuaOutputSubset() returned non-zero return code.

After

...
testLuaOutputPretty
testLuaOutputSubset

Ran 17 tests.

OK

@mikefarah mikefarah merged commit 7c78a15 into mikefarah:master Oct 12, 2023
3 checks passed
@Zash Zash deleted the luaoutfixes branch October 12, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants