diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 8485d405..841282f5 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -15,6 +15,9 @@ import "src:server" Package :: struct { pkg: string, source: string, + // Allows you to directly specify the file path. + // If it's 'test/.odin', it will share the same package as the main file. + file: string, } Source :: struct { @@ -78,7 +81,11 @@ setup :: proc(src: ^Source) { for src_pkg in src.packages { context.allocator = virtual.arena_allocator(src.document.allocator) - uri := common.create_uri(fmt.aprintf("test/%v/package.odin", src_pkg.pkg), context.temp_allocator) + path := src_pkg.file + if path == "" { + path = fmt.aprintf("test/%v/package.odin", src_pkg.pkg) + } + uri := common.create_uri(path, context.temp_allocator) fullpath := uri.path @@ -162,7 +169,11 @@ expect_signature_labels :: proc( if expected_active_parameter != -1 { if expected_active_parameter != help.activeParameter { - log.errorf("Expected active parameter %v, but reveived %v", expected_active_parameter, help.activeParameter) + log.errorf( + "Expected active parameter %v, but reveived %v", + expected_active_parameter, + help.activeParameter, + ) } } } diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 69f10aa6..df1e2e3d 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -6852,3 +6852,28 @@ ast_hover_enum_case_with_range :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.Foo: .A") } + +@(test) +ast_hover_test_with_mulitple_files :: proc(t: ^testing.T) { + packages := make([dynamic]test.Package, context.temp_allocator) + + append( + &packages, + test.Package { + pkg = "test", + file = "test/test2.odin", + source = `package test + Bar :: struct{} + `, + } + ) + source := test.Source { + main = `package test + main :: proc() { + bar: B{*}ar + } + `, + packages = packages[:], + } + test.expect_hover(t, &source, "test.Bar :: struct{}") +}