diff --git a/spec/cli/types_spec.lua b/spec/cli/types_spec.lua index c94b51d7a..4c5393ded 100644 --- a/spec/cli/types_spec.lua +++ b/spec/cli/types_spec.lua @@ -4,6 +4,13 @@ local util = require("spec.util") describe("tl types works like check", function() describe("on .tl files", function() + it("reports missing files", function() + local pd = io.popen(util.tl_cmd("types", "nonexistent_file") .. "2>&1 1>" .. util.os_null, "r") + local output = pd:read("*a") + util.assert_popen_close(1, pd:close()) + assert.match("could not open nonexistent_file", output, 1, true) + end) + it("works on empty files", function() local name = util.write_tmp_file(finally, [[]]) local pd = io.popen(util.tl_cmd("types", name) .. " 2>" .. util.os_null, "r") diff --git a/tl b/tl index 3e4a69ea4..973c0039c 100755 --- a/tl +++ b/tl @@ -897,15 +897,23 @@ do env.report_types = true for i, input_file in ipairs(args["file"]) do - local pok, err = pcall(process_module, input_file, env) + local pok, perr, err = pcall(process_module, input_file, env) if not pok then - die("Internal Compiler Error: " .. err) + die("Internal Compiler Error: " .. perr) end + if err then + printerr(err) + end + check_collect(i) end local ok, _, _, w = report_all_errors(tlconfig, env) + if not env.reporter then + os.exit(1) + end + local tr = env.reporter:get_report() if tr then if w or not ok then