Skip to content

Commit

Permalink
Merge pull request #624 from pallene-lang/pt-tag-adopt
Browse files Browse the repository at this point in the history
Adaptation of version specific Pallene Tracer
  • Loading branch information
hugomg authored Aug 15, 2024
2 parents 9719c62 + bb7df30 commit d3988d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:
env:
LUA_VERSION: 5.4.7
LUAROCKS_VERSION: 3.9.0
PT_VERSION: 0.5.0a

jobs:
lint:
Expand Down Expand Up @@ -79,7 +80,7 @@ jobs:
- name: Install Pallene Tracer
run: |
git clone https://github.com/pallene-lang/pallene-tracer
git clone --depth 1 https://github.com/pallene-lang/pallene-tracer --branch ${{env.PT_VERSION}}
cd pallene-tracer
make LUA_PREFIX=/usr/local
sudo make install
Expand Down
35 changes: 20 additions & 15 deletions spec/traceback_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@ local function assert_test(test, expected_traceback)
end

local luafile = util.shell_quote("spec/traceback/"..test.."/main.lua")
local ok, _, output_content, err_content = util.outputs_of_execute("pt-run "..luafile)
local ok, _, output_content, err_content = util.outputs_of_execute("pt-lua "..luafile)
assert(not ok, output_content)
assert.are.same(expected_traceback, err_content)
end

it("Rectangle", function()
assert_test("rect", [[
Runtime error: spec/traceback/rect/main.lua:8: file spec/traceback/rect/rect.pln: line 10: wrong type for downcasted value, expected float but found string
Stack traceback:
pt-lua: spec/traceback/rect/main.lua:8: file spec/traceback/rect/rect.pln: line 10: wrong type for downcasted value, expected float but found string
stack traceback:
spec/traceback/rect/rect.pln:10: in function 'universal_calc_area'
spec/traceback/rect/rect.pln:13: in function 'area'
spec/traceback/rect/main.lua:8: in <main>
C: in function '<?>'
]])
end)

it("Multi-module Lua", function()
assert_test("module_lua", [[
Runtime error: spec/traceback/module_lua/main.lua:25: Any normal error from Lua!
Stack traceback:
pt-lua: spec/traceback/module_lua/main.lua:25: Any normal error from Lua!
stack traceback:
C: in function 'error'
spec/traceback/module_lua/main.lua:25: in function 'lua_3'
spec/traceback/module_lua/module_lua.pln:12: in function 'pallene_2'
Expand All @@ -46,26 +47,28 @@ Stack traceback:
spec/traceback/module_lua/main.lua:12: in function 'callback'
./spec/traceback/module_lua/another_module.lua:7: in function 'call_lua_callback'
spec/traceback/module_lua/main.lua:28: in <main>
C: in function '<?>'
]])
end)

it("Multi-module Pallene", function()
assert_test("module_pallene", [[
Runtime error: spec/traceback/module_pallene/main.lua:11: There's an error in everyday life. Alas!
Stack traceback:
pt-lua: spec/traceback/module_pallene/main.lua:11: There's an error in everyday life. Alas!
stack traceback:
C: in function 'error'
spec/traceback/module_pallene/main.lua:11: in function 'lua_2'
spec/traceback/module_pallene/module_pallene_alt.pln:8: in function 'alternate_everyday_fn'
spec/traceback/module_pallene/main.lua:16: in function 'lua_1'
spec/traceback/module_pallene/module_pallene.pln:8: in function 'normal_everyday_fn'
spec/traceback/module_pallene/main.lua:19: in <main>
C: in function '<?>'
]])
end)

it("Depth recursion", function()
assert_test("depth_recursion", [[
Runtime error: spec/traceback/depth_recursion/main.lua:11: Depth reached 0!
Stack traceback:
pt-lua: spec/traceback/depth_recursion/main.lua:11: Depth reached 0!
stack traceback:
C: in function 'error'
spec/traceback/depth_recursion/main.lua:11: in function 'lua_fn'
spec/traceback/depth_recursion/depth_recursion.pln:8: in function 'pallene_fn'
Expand All @@ -79,13 +82,14 @@ Stack traceback:
spec/traceback/depth_recursion/depth_recursion.pln:8: in function 'pallene_fn'
spec/traceback/depth_recursion/main.lua:14: in function 'lua_fn'
spec/traceback/depth_recursion/main.lua:17: in <main>
C: in function '<?>'
]])
end)

it("Stack overflow", function()
assert_test("stack_overflow", [[
Runtime error: C stack overflow
Stack traceback:
pt-lua: C stack overflow
stack traceback:
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
Expand All @@ -97,9 +101,8 @@ Stack traceback:
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
... (Skipped 380 frames) ...
... (Skipped 379 frames) ...
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
Expand All @@ -109,16 +112,18 @@ Stack traceback:
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/main.lua:13: in <main>
C: in function '<?>'
]])
end)

it("Anonymous lua functions", function()
assert_test("anon_lua", [[
Runtime error: spec/traceback/anon_lua/main.lua:9: Error from an anonymous Lua fn!
Stack traceback:
pt-lua: spec/traceback/anon_lua/main.lua:9: Error from an anonymous Lua fn!
stack traceback:
C: in function 'error'
spec/traceback/anon_lua/main.lua:9: in function '<?>'
spec/traceback/anon_lua/anon_lua.pln:8: in function 'call_anon_lua_fn'
spec/traceback/anon_lua/main.lua:8: in <main>
C: in function '<?>'
]])
end)

0 comments on commit d3988d0

Please sign in to comment.