From 8632e68351bcd19d46b8a6f32ddec330f845eace Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 9 Oct 2024 19:09:20 -0400 Subject: [PATCH] tests: move some CLI tests around --- spec/{lang => cli}/config/errors.lua | 0 spec/cli/run_spec.lua | 11 +++++++ .../error_reporting/module_error_spec.lua | 31 ------------------- 3 files changed, 11 insertions(+), 31 deletions(-) rename spec/{lang => cli}/config/errors.lua (100%) delete mode 100644 spec/lang/error_reporting/module_error_spec.lua diff --git a/spec/lang/config/errors.lua b/spec/cli/config/errors.lua similarity index 100% rename from spec/lang/config/errors.lua rename to spec/cli/config/errors.lua diff --git a/spec/cli/run_spec.lua b/spec/cli/run_spec.lua index 26f9d7335..2b14316b7 100644 --- a/spec/cli/run_spec.lua +++ b/spec/cli/run_spec.lua @@ -370,4 +370,15 @@ describe("tl run", function() end) end) + it("compilation errors should be caught when loading modules", function() + util.run_mock_project(finally, { + dir_structure = { + ["my_module.tl"] = [[todo, write module :)]], + ["my_script.tl"] = [[local mod = require("my_module"); mod.do_things()]], + }, + cmd = "run", + args = { "my_script.tl" }, + exit_code = 1, + }) + end) end) diff --git a/spec/lang/error_reporting/module_error_spec.lua b/spec/lang/error_reporting/module_error_spec.lua deleted file mode 100644 index f0265a835..000000000 --- a/spec/lang/error_reporting/module_error_spec.lua +++ /dev/null @@ -1,31 +0,0 @@ -local tl = require("tl") -local util = require("spec.util") - -describe("Uncaught compiler errors", function() - local old_parse_program - setup(function() - old_parse_program = tl.parse_program - tl.parse_program = function(tokens, _, chunkname) - return old_parse_program(tokens, {}, chunkname) - end - end) - teardown(function() - tl.parse_program = old_parse_program - end) - it("should be reported when loading modules", function() - util.run_mock_project(finally, { - dir_structure = { - ["my_module.tl"] = [[todo, write module :)]], - ["my_script.tl"] = [[local mod = require("my_module"); mod.do_things()]], - }, - cmd = "run", - args = { "my_script.tl" }, - generated_files = {}, - popen = { - status = nil, - exit = "exit", - code = 1, - }, - }) - end) -end)