diff --git a/src/main/resources/data/computercraft/lua/rom/programs/import.lua b/src/main/resources/data/computercraft/lua/rom/programs/import.lua index 54c073864..027357ea8 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/import.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/import.lua @@ -18,7 +18,7 @@ if #files == 0 then return end -package.path = package.path .. "/rom/modules/internal/?.lua" +package.path = package.path .. ";/rom/modules/internal/?.lua" local ok, err = require("cc.import")(files) if not ok and err then printError(err) end diff --git a/src/test/resources/test-rom/spec/programs/import_spec.lua b/src/test/resources/test-rom/spec/programs/import_spec.lua new file mode 100644 index 000000000..8eb58624d --- /dev/null +++ b/src/test/resources/test-rom/spec/programs/import_spec.lua @@ -0,0 +1,36 @@ +local with_window = require "test_helpers".with_window + +describe("The import program", function() + local function create_file(name, contents) + local did_read = false + return { + getName = function() return name end, + read = function() + if did_read then return end + did_read = true + return contents + end, + close = function() end, + } + end + local function create_files(files) return { getFiles = function() return files end } end + + it("uploads files", function() + fs.delete("transfer.txt") + + with_window(32, 5, function() + local queue = { + { "import" }, + { "file_transfer", create_files { create_file("transfer.txt", "empty file") } }, + } + local co = coroutine.create(shell.run) + for _, event in pairs(queue) do assert(coroutine.resume(co, table.unpack(event))) end + end) + + local handle = fs.open("transfer.txt", "rb") + local contents = handle.readAll() + handle.close() + + expect(contents):eq("empty file") + end) +end) diff --git a/src/test/resources/test-rom/spec/programs/shell_spec.lua b/src/test/resources/test-rom/spec/programs/shell_spec.lua index 0e88983ae..5b1645d46 100644 --- a/src/test/resources/test-rom/spec/programs/shell_spec.lua +++ b/src/test/resources/test-rom/spec/programs/shell_spec.lua @@ -120,7 +120,7 @@ describe("The shell", function() local function create_files(files) return { getFiles = function() return files end } end it("suspends the read prompt", function() - fs.delete("tmp.txt") + fs.delete("transfer.txt") local win = with_window(32, 5, function() local queue = {