Informative error message when `LoadFile` fails

Đang mở
#18 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go, lua
Lĩnh vực
testing-qa

Hướng nghiên cứu

The generic file error comes from the script-loading step in lua_test_runner.go around line 31, which hides the underlying error from the Lua load call. Start there and check what error value the load returns for a missing file versus a syntax error. Done when RunLuaTests reports the actual cause (the file path or the Lua syntax message) for both cases, and the two failure cases in the issue print distinct messages.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

Proposed solution

Provide more context as to what failed with the call.

Problem

At this time, both a syntax error or a missing file show up as file error:

Missing file:

func TestLuaRegexp(t *testing.T) {
    l := lua.NewState()
    lua.OpenLibraries(l)
    regexp.Open(l)
    luatest.RunLuaTests(t, l, "im_not_a_file.lua")
    // luatest.RunLuaTests(t, l, "regexp_test.lua")
}
// --- FAIL: TestLuaRegexp (0.00 seconds)
//         lua_test_runner.go:31: loading lua test script in VM, file error

Syntax error (in regexp_test.lua):

local re = require("goluago/regexp")

derp!

-- quotemeta
equals("quotemeta: example", "\\[foo\\]", re.quotemeta("[foo]"))
func TestLuaRegexp(t *testing.T) {
    l := lua.NewState()
    lua.OpenLibraries(l)
    regexp.Open(l)
    luatest.RunLuaTests(t, l, "regexp_test.lua")
}
// --- FAIL: TestLuaRegexp (0.00 seconds)
//         lua_test_runner.go:31: loading lua test script in VM, file error
Ngôn ngữ chính
Go
Star
3.5k
Fork
217
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Shopify/go-lua

Tất cả issue của Shopify/go-lua

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.