From c8826923ea51ac3b512c385e0fece81f8341c7c5 Mon Sep 17 00:00:00 2001 From: Andrew Condon Date: Sat, 10 Jan 2026 15:31:56 +0100 Subject: [PATCH] feat: migrate test project from spago.dhall to spago.yaml Migrate the test PureScript project to use the new spago.yaml format, enabling compatibility with spago 0.93+ which dropped support for dhall-based configuration. Changes: - Add test/ps/spago.yaml with extraPackages pointing to Lua-compatible forks (purescript-lua-prelude, purescript-lua-effect, etc.) - Update Golden/Spec.hs to use `spago build` instead of the deprecated `spago build -u '-g corefn'` (new spago generates corefn by default) - Update .gitignore to exclude spago build artifacts (library dependencies) while keeping Golden.* test directories - Regenerate golden files with updated package versions The Lua-compatible packages are sourced from: - https://github.com/Unisay/purescript-lua-* - https://github.com/purescript-lua/purescript-lua-* Co-Authored-By: Claude Opus 4.5 --- .../PureScript/Backend/Lua/Golden/Spec.hs | 4 +- test/ps/.gitignore | 16 ++ .../Golden.ArrayOfUnits.Test/eval/golden.txt | 4 - .../output/Golden.ArrayOfUnits.Test/golden.ir | 12 +- .../Golden.ArrayOfUnits.Test/golden.lua | 48 ++-- .../Golden.Fibonacci.Test/eval/golden.txt | 1 - .../ps/output/Golden.Fibonacci.Test/golden.ir | 8 +- .../output/Golden.Fibonacci.Test/golden.lua | 5 +- .../output/Golden.HelloPrelude.Test/golden.ir | 4 +- .../Golden.HelloPrelude.Test/golden.lua | 2 +- test/ps/spago.yaml | 205 ++++++++++++++++++ 11 files changed, 265 insertions(+), 44 deletions(-) delete mode 100644 test/ps/output/Golden.ArrayOfUnits.Test/eval/golden.txt delete mode 100644 test/ps/output/Golden.Fibonacci.Test/eval/golden.txt create mode 100644 test/ps/spago.yaml diff --git a/test/Language/PureScript/Backend/Lua/Golden/Spec.hs b/test/Language/PureScript/Backend/Lua/Golden/Spec.hs index e712f35..8c7b904 100644 --- a/test/Language/PureScript/Backend/Lua/Golden/Spec.hs +++ b/test/Language/PureScript/Backend/Lua/Golden/Spec.hs @@ -75,10 +75,10 @@ spec ∷ Spec spec = do describe "Goldens: *.purs -> *.lua" do let compilePs = do - putText "Comipling PureScript sources" + putText "Compiling PureScript sources" exitCode ← runProcess . setWorkingDir "test/ps" . shell $ - String.unwords ["spago", "build", "-u", "'-g corefn'"] + String.unwords ["spago", "build"] exitCode `shouldBe` ExitSuccess psOutputPath = $(mkRelDir "test/ps/output/") diff --git a/test/ps/.gitignore b/test/ps/.gitignore index aca89d6..87103e3 100644 --- a/test/ps/.gitignore +++ b/test/ps/.gitignore @@ -5,6 +5,7 @@ /output/*/*.json !/output/Golden*/corefn.json /output/*/*.js +/output/*/*.js.map /output/*/actual.* /output/*.json /output-es/ @@ -14,3 +15,18 @@ /.purs* /.psa* /.spago + +# Spago build artifacts (library dependencies) +# Only Golden.* test directories should be tracked +/output/Control.*/ +/output/Data.*/ +/output/Effect*/ +/output/Prelude/ +/output/Record.*/ +/output/Safe.*/ +/output/Spago.*/ +/output/Type.*/ +/output/Unsafe.*/ + +# Spago lock file (regenerated on build) +/spago.lock diff --git a/test/ps/output/Golden.ArrayOfUnits.Test/eval/golden.txt b/test/ps/output/Golden.ArrayOfUnits.Test/eval/golden.txt deleted file mode 100644 index 8786a2d..0000000 --- a/test/ps/output/Golden.ArrayOfUnits.Test/eval/golden.txt +++ /dev/null @@ -1,4 +0,0 @@ -unit -unit -unit -3 diff --git a/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir b/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir index 52e2626..d730652 100644 --- a/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir +++ b/test/ps/output/Golden.ArrayOfUnits.Test/golden.ir @@ -4,25 +4,25 @@ UberModule ( QName { qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign" }, ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.0/src/Data/Unit.purs" + ( ModuleName "Data.Unit" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Unit.purs" [ ( Just Always, Name "unit" ) ] ), Standalone ( QName { qnameModuleName = ModuleName "Data.Semiring", qnameName = Name "foreign" }, ForeignImport Nothing - ( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.0/src/Data/Semiring.purs" + ( ModuleName "Data.Semiring" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Semiring.purs" [ ( Nothing, Name "intAdd" ), ( Nothing, Name "intMul" ) ] ), Standalone ( QName { qnameModuleName = ModuleName "Data.Foldable", qnameName = Name "foreign" }, ForeignImport Nothing - ( ModuleName "Data.Foldable" ) ".spago/foldable-traversable/v6.1.0/src/Data/Foldable.purs" + ( ModuleName "Data.Foldable" ) ".spago/p/foldable-traversable/18a7d55fa2e87d3f2c557e24f89e197bd30c4f25/src/Data/Foldable.purs" [ ( Nothing, Name "foldrArray" ), ( Nothing, Name "foldlArray" ) ] ), Standalone ( QName { qnameModuleName = ModuleName "Effect", qnameName = Name "foreign" }, ForeignImport Nothing - ( ModuleName "Effect" ) ".spago/effect/v4.1.0/src/Effect.purs" + ( ModuleName "Effect" ) ".spago/p/effect/ee3f5984b9d68c3e116eeb44da09dcb8714c9c66/src/Effect.purs" [ ( Nothing, Name "pureE" ), ( Nothing, Name "bindE" ) ] ), Standalone ( QName @@ -339,7 +339,7 @@ UberModule ( App Nothing ( ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/console/v6.1.0/src/Effect/Console.purs" + ( ModuleName "Effect.Console" ) ".spago/p/console/66f1ba20176dd9b35aff47b45f13fd17582683b1/src/Effect/Console.purs" [ ( Nothing, Name "log" ) ] ) ( PropName "log" ) @@ -520,7 +520,7 @@ UberModule [ ( PropName "show", ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs" + ( ModuleName "Data.Show" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ) ( PropName "showIntImpl" ) diff --git a/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua b/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua index b02e938..98bcb67 100644 --- a/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua +++ b/test/ps/output/Golden.ArrayOfUnits.Test/golden.lua @@ -19,7 +19,7 @@ local function PSLUA_runtime_lazy(name) end end local M = {} -M.Data_Unit_foreign = { unit = {} } +M.Data_Unit_foreign = { unit = nil } M.Data_Semiring_foreign = { intAdd = function(x) return function(y) return x + y end end, intMul = function(x) return function(y) return x * y end end @@ -127,25 +127,27 @@ M.Effect_Console_logShow = function(dictShow) return (function(s) return function() print(s) end end)(dictShow.show(a)) end end -return (function() - local arr = { - [1] = M.Data_Unit_foreign.unit, - [2] = M.Data_Unit_foreign.unit, - [3] = M.Data_Unit_foreign.unit - } - return M.Control_Bind_bind(M.Effect_bindEffect)(M.Data_Foldable_foldr(M.Data_Foldable_foldableArray)(M.Control_Semigroupoid_semigroupoidFn.compose(function( a ) - return M.Control_Apply_apply(M.Effect_applicativeEffect.Apply0())(((M.Effect_applicativeEffect.Apply0()).Functor0()).map(function( ) - return function(x) return x end - end)(a)) - end)(M.Effect_Console_logShow({ - show = function() return "unit" end - })))(M.Control_Applicative_pure(M.Effect_applicativeEffect)(M.Data_Unit_foreign.unit))(arr))(function( ) - return M.Effect_Console_logShow({ - show = function(n) return tostring(n) end - })(M.Data_Foldable_foldableArray.foldl(function(c) - return function() - return M.Data_Semiring_semiringInt.add(M.Data_Semiring_semiringInt.one)(c) - end - end)(M.Data_Semiring_semiringInt.zero)(arr)) - end) -end)()() +return { + main = (function() + local arr = { + [1] = M.Data_Unit_foreign.unit, + [2] = M.Data_Unit_foreign.unit, + [3] = M.Data_Unit_foreign.unit + } + return M.Control_Bind_bind(M.Effect_bindEffect)(M.Data_Foldable_foldr(M.Data_Foldable_foldableArray)(M.Control_Semigroupoid_semigroupoidFn.compose(function( a ) + return M.Control_Apply_apply(M.Effect_applicativeEffect.Apply0())(((M.Effect_applicativeEffect.Apply0()).Functor0()).map(function( ) + return function(x) return x end + end)(a)) + end)(M.Effect_Console_logShow({ + show = function() return "unit" end + })))(M.Control_Applicative_pure(M.Effect_applicativeEffect)(M.Data_Unit_foreign.unit))(arr))(function( ) + return M.Effect_Console_logShow({ + show = function(n) return tostring(n) end + })(M.Data_Foldable_foldableArray.foldl(function(c) + return function() + return M.Data_Semiring_semiringInt.add(M.Data_Semiring_semiringInt.one)(c) + end + end)(M.Data_Semiring_semiringInt.zero)(arr)) + end) + end)() +} diff --git a/test/ps/output/Golden.Fibonacci.Test/eval/golden.txt b/test/ps/output/Golden.Fibonacci.Test/eval/golden.txt deleted file mode 100644 index 2eb03fe..0000000 --- a/test/ps/output/Golden.Fibonacci.Test/eval/golden.txt +++ /dev/null @@ -1 +0,0 @@ -2178309 diff --git a/test/ps/output/Golden.Fibonacci.Test/golden.ir b/test/ps/output/Golden.Fibonacci.Test/golden.ir index 8296ee6..30b97bf 100644 --- a/test/ps/output/Golden.Fibonacci.Test/golden.ir +++ b/test/ps/output/Golden.Fibonacci.Test/golden.ir @@ -4,7 +4,7 @@ UberModule ( QName { qnameModuleName = ModuleName "Data.Semiring", qnameName = Name "foreign" }, ForeignImport Nothing - ( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.0/src/Data/Semiring.purs" + ( ModuleName "Data.Semiring" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Semiring.purs" [ ( Nothing, Name "intAdd" ), ( Nothing, Name "intMul" ) ] ), Standalone ( QName @@ -30,7 +30,7 @@ UberModule [ ( PropName "sub", ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Data.Ring" ) ".spago/prelude/v7.2.0/src/Data/Ring.purs" + ( ModuleName "Data.Ring" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Ring.purs" [ ( Nothing, Name "intSub" ) ] ) ( PropName "intSub" ) @@ -103,7 +103,7 @@ UberModule ( Name "main", App Nothing ( ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Effect.Console" ) ".spago/console/v6.1.0/src/Effect/Console.purs" + ( ModuleName "Effect.Console" ) ".spago/p/console/66f1ba20176dd9b35aff47b45f13fd17582683b1/src/Effect/Console.purs" [ ( Nothing, Name "log" ) ] ) ( PropName "log" ) @@ -114,7 +114,7 @@ UberModule [ ( PropName "show", ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs" + ( ModuleName "Data.Show" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Show.purs" [ ( Nothing, Name "showIntImpl" ) ] ) ( PropName "showIntImpl" ) diff --git a/test/ps/output/Golden.Fibonacci.Test/golden.lua b/test/ps/output/Golden.Fibonacci.Test/golden.lua index 047d996..29a842f 100644 --- a/test/ps/output/Golden.Fibonacci.Test/golden.lua +++ b/test/ps/output/Golden.Fibonacci.Test/golden.lua @@ -21,4 +21,7 @@ M.Golden_Fibonacci_Test_fib = function(v) end end end -return (function(s) return function() print(s) end end)((function(n) return tostring(n) end)(M.Golden_Fibonacci_Test_fib(32)))() +return { + fib = M.Golden_Fibonacci_Test_fib, + main = (function(s) return function() print(s) end end)((function(n) return tostring(n) end)(M.Golden_Fibonacci_Test_fib(32))) +} diff --git a/test/ps/output/Golden.HelloPrelude.Test/golden.ir b/test/ps/output/Golden.HelloPrelude.Test/golden.ir index e7afbf6..cf8683b 100644 --- a/test/ps/output/Golden.HelloPrelude.Test/golden.ir +++ b/test/ps/output/Golden.HelloPrelude.Test/golden.ir @@ -4,7 +4,7 @@ UberModule ( QName { qnameModuleName = ModuleName "Effect", qnameName = Name "foreign" }, ForeignImport Nothing - ( ModuleName "Effect" ) ".spago/effect/v4.1.0/src/Effect.purs" + ( ModuleName "Effect" ) ".spago/p/effect/ee3f5984b9d68c3e116eeb44da09dcb8714c9c66/src/Effect.purs" [ ( Nothing, Name "pureE" ), ( Nothing, Name "bindE" ) ] ), Standalone ( QName @@ -206,7 +206,7 @@ UberModule ) ( ObjectProp ( Just Always ) ( ForeignImport Nothing - ( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.0/src/Data/Unit.purs" + ( ModuleName "Data.Unit" ) ".spago/p/prelude/384b74cec7d51a2fa20baad3768cf00575aedf63/src/Data/Unit.purs" [ ( Just Always, Name "unit" ) ] ) ( PropName "unit" ) diff --git a/test/ps/output/Golden.HelloPrelude.Test/golden.lua b/test/ps/output/Golden.HelloPrelude.Test/golden.lua index 16977dd..37b7c0c 100644 --- a/test/ps/output/Golden.HelloPrelude.Test/golden.lua +++ b/test/ps/output/Golden.HelloPrelude.Test/golden.lua @@ -70,4 +70,4 @@ M.Effect_Lazy_applyEffect = PSLUA_runtime_lazy("applyEffect")(function() Functor0 = function() return M.Effect_Lazy_functorEffect(0) end } end) -return { main = M.Control_Applicative_pure(M.Effect_applicativeEffect)({}) } +return { main = M.Control_Applicative_pure(M.Effect_applicativeEffect)(nil) } diff --git a/test/ps/spago.yaml b/test/ps/spago.yaml new file mode 100644 index 0000000..56987b1 --- /dev/null +++ b/test/ps/spago.yaml @@ -0,0 +1,205 @@ +# PureScript Lua Test Project +# Migrated from spago.dhall to spago.yaml format +# +# This project uses Lua-compatible forks of core PureScript packages +# maintained at https://github.com/Unisay/purescript-lua-* + +package: + name: test-project + dependencies: + - console + - effect + - foldable-traversable + - prelude + +workspace: + packageSet: + registry: 67.0.1 + + # Lua-compatible package overrides from purescript-lua-package-sets + extraPackages: + assert: + git: https://github.com/Unisay/purescript-lua-assert.git + ref: v6.1.0 + dependencies: + - effect + - console + - prelude + + arrays: + git: https://github.com/Unisay/purescript-lua-arrays.git + ref: v7.3.0 + dependencies: + - foldable-traversable + - functions + - nonempty + - partial + - prelude + - st + - unfoldable + - unsafe-coerce + + console: + git: https://github.com/Unisay/purescript-lua-console.git + ref: v6.1.0 + dependencies: + - effect + - prelude + + control: + git: https://github.com/Unisay/purescript-lua-control.git + ref: v6.0.0 + dependencies: + - newtype + - prelude + + effect: + git: https://github.com/Unisay/purescript-lua-effect.git + ref: v4.1.0 + dependencies: + - prelude + + enums: + git: https://github.com/Unisay/purescript-lua-enums.git + ref: v6.1.0 + dependencies: + - control + - either + - gen + - maybe + - newtype + - nonempty + - partial + - prelude + - tuples + - unfoldable + + exceptions: + git: https://github.com/Unisay/purescript-lua-exceptions.git + ref: v6.1.0 + dependencies: + - effect + - either + - maybe + - prelude + + functions: + git: https://github.com/Unisay/purescript-lua-functions.git + ref: v6.1.0 + dependencies: + - prelude + + lazy: + git: https://github.com/Unisay/purescript-lua-lazy.git + ref: v7.0.0 + dependencies: + - control + - foldable-traversable + - invariant + - prelude + + integers: + git: https://github.com/Unisay/purescript-lua-integers.git + ref: v6.1.0 + dependencies: + - maybe + - numbers + - prelude + + numbers: + git: https://github.com/Unisay/purescript-lua-numbers.git + ref: v9.1.0 + dependencies: + - functions + - maybe + - prelude + + partial: + git: https://github.com/Unisay/purescript-lua-partial.git + ref: v4.1.0 + dependencies: [] + + prelude: + git: https://github.com/Unisay/purescript-lua-prelude.git + ref: v7.1.2 + dependencies: [] + + refs: + git: https://github.com/Unisay/purescript-lua-refs.git + ref: v6.1.0 + dependencies: + - effect + - prelude + + safe-coerce: + git: https://github.com/Unisay/purescript-lua-safe-coerce.git + ref: v2.0.0 + dependencies: + - unsafe-coerce + + st: + git: https://github.com/purescript-lua/purescript-lua-st.git + ref: v6.3.0 + dependencies: + - partial + - prelude + - tailrec + - unsafe-coerce + + strings: + git: https://github.com/Unisay/purescript-lua-strings.git + ref: v6.1.0 + dependencies: + - arrays + - enums + - foldable-traversable + - gen + - integers + - maybe + - newtype + - nonempty + - partial + - prelude + - tailrec + - tuples + - unfoldable + - unsafe-coerce + + unfoldable: + git: https://github.com/Unisay/purescript-lua-unfoldable.git + ref: v6.1.0 + dependencies: + - foldable-traversable + - maybe + - partial + - prelude + - tuples + + unsafe-coerce: + git: https://github.com/Unisay/purescript-lua-unsafe-coerce.git + ref: v6.1.0 + dependencies: [] + + foldable-traversable: + git: https://github.com/Unisay/purescript-lua-foldable-traversable.git + ref: v6.1.0 + dependencies: + - bifunctors + - const + - control + - either + - functors + - identity + - maybe + - newtype + - orders + - prelude + - tuples + + # Lua/Nginx bindings + lua-ngx: + git: https://github.com/Unisay/purescript-lua-ngx.git + ref: v0.2.0 + dependencies: + - effect + - prelude