-
Notifications
You must be signed in to change notification settings - Fork 260
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
style: format Lua files #3819
style: format Lua files #3819
Conversation
we choose to use dprint because: - its plugin system is useful when unifying formatters - deno uses dprint internally, thus less migration debt - lua IDE formatter is hard to set up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not qualified to review this since zero LUA experience but Scarf kept pestering me to do so in the discord, so uh. This looks like a relevant error in the check failure log:
Log:
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> lua_runtime_error
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:121
(~[slow] ~[.],starting_items)=> ...............................................................................
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:134: FAILED:
(~[slow] ~[.],starting_items)=> REQUIRE_THROWS_MATCHES( run_lua_test_script( lua, "runtime_error.lua" ), std::runtime_error, Catch::Message( expected ) )
(~[slow] ~[.],starting_items)=> with expansion:
(~[slow] ~[.],starting_items)=> Script runtime error in tests/lua/runtime_error.lua: tests/lua/runtime_error.
(~[slow] ~[.],starting_items)=> lua:2: attempt to index a nil value (global 'table_with_typo')
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> tests/lua/runtime_error.lua:2: in main chunk exception message matches
(~[slow] ~[.],starting_items)=> "Script runtime error in tests/lua/runtime_error.lua: tests/lua/
(~[slow] ~[.],starting_items)=> runtime_error.lua:3: attempt to index a nil value (global 'table_with_typo')
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> tests/lua/runtime_error.lua:3: in main chunk"
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> lua_called_error_on_lua_side
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:141
(~[slow] ~[.],starting_items)=> ...............................................................................
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:155: FAILED:
(~[slow] ~[.],starting_items)=> REQUIRE_THROWS_MATCHES( run_lua_test_script( lua, "called_error_on_lua_side.lua" ), std::runtime_error, Catch::Message( expected ) )
(~[slow] ~[.],starting_items)=> with expansion:
(~[slow] ~[.],starting_items)=> Script runtime error in tests/lua/called_error_on_lua_side.lua: tests/lua/
(~[slow] ~[.],starting_items)=> called_error_on_lua_side.lua:2: Error called on Lua side!
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> [C]: in function 'base.error'
(~[slow] ~[.],starting_items)=> tests/lua/called_error_on_lua_side.lua:2: in main chunk exception message
(~[slow] ~[.],starting_items)=> matches "Script runtime error in tests/lua/called_error_on_lua_side.lua:
(~[slow] ~[.],starting_items)=> tests/lua/called_error_on_lua_side.lua:3: Error called on Lua side!
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> [C]: in function 'base.error'
(~[slow] ~[.],starting_items)=> tests/lua/called_error_on_lua_side.lua:3: in main chunk"
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> lua_called_error_on_cpp_side
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:167
(~[slow] ~[.],starting_items)=> ...............................................................................
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:183: FAILED:
(~[slow] ~[.],starting_items)=> REQUIRE_THROWS_MATCHES( run_lua_test_script( lua, "called_error_on_cpp_side.lua" ), std::runtime_error, Catch::Message( expected ) )
(~[slow] ~[.],starting_items)=> with expansion:
(~[slow] ~[.],starting_items)=> Script runtime error in tests/lua/called_error_on_cpp_side.lua: tests/lua/
(~[slow] ~[.],starting_items)=> called_error_on_cpp_side.lua:2: Error called on Cpp side!
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> [C]: in function 'base.cpp_call_error'
(~[slow] ~[.],starting_items)=> tests/lua/called_error_on_cpp_side.lua:2: in main chunk exception message
(~[slow] ~[.],starting_items)=> matches "Script runtime error in tests/lua/called_error_on_cpp_side.lua:
(~[slow] ~[.],starting_items)=> tests/lua/called_error_on_cpp_side.lua:3: Error called on Cpp side!
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> [C]: in function 'base.cpp_call_error'
(~[slow] ~[.],starting_items)=> tests/lua/called_error_on_cpp_side.lua:3: in main chunk"
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> [sol2] An exception occurred: Exception thrown on Cpp side!
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> lua_called_cpp_func_throws
(~[slow] ~[.],starting_items)=> -------------------------------------------------------------------------------
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:196
(~[slow] ~[.],starting_items)=> ...............................................................................
(~[slow] ~[.],starting_items)=>
(~[slow] ~[.],starting_items)=> /home/runner/work/Cataclysm-BN/Cataclysm-BN/tests/catalua_test.cpp:212: FAILED:
(~[slow] ~[.],starting_items)=> REQUIRE_THROWS_MATCHES( run_lua_test_script( lua, "called_cpp_func_throws.lua" ), std::runtime_error, Catch::Message( expected ) )
(~[slow] ~[.],starting_items)=> with expansion:
(~[slow] ~[.],starting_items)=> Script runtime error in tests/lua/called_cpp_func_throws.lua: Exception
(~[slow] ~[.],starting_items)=> thrown on Cpp side!
(~[slow] ~[.],starting_items)=> stack traceback:
(~[slow] ~[.],starting_items)=> [C]: in function 'base.cpp_throw_exception'
(~[slow] ~[.],starting_items)=> tests/lua/called_cpp_func_throws.lua:2: in main chunk exception message
...right, because the code is formatted the errors are also formatted, so i need to change the tests as well. |
b2fefd5
to
f610695
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, yeet.
f3d7db3
Purpose of change
Using formatter improves readability and diff output.
Describe the solution
use https://github.com/RubixDev/dprint-plugin-stylua to format Lua files.
Why dprint?
dprint
internally, so it's easy to migrate in the future.dprint
VSCode extensiondeno task dprint fmt
Alternatives
migrate formatting ecosystem to use
dprint
with its configuration set to match withdeno
.Additional Context
followup task for #3165