From 9827672c4549c56a71e3993a59b1044534d8d208 Mon Sep 17 00:00:00 2001 From: Matthias Simon Date: Sun, 3 Nov 2024 12:29:00 +0100 Subject: [PATCH] Discover: Always return a possible directory. Discover is used by the language server to find the root of a project. If the root is not found, it will now return the initial directory. Closes #709 --- project/project.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/project/project.go b/project/project.go index d244d28c..15b8892e 100644 --- a/project/project.go +++ b/project/project.go @@ -268,7 +268,7 @@ func Discover(path string) []Suite { } list = append(list, readIndices(fs.JoinPath(path, IndexFile))...) - // Check build directories + // Check parallel build directories for _, file := range fs.Glob(path + "/*build*/" + IndexFile) { list = append(list, readIndices(file)...) } @@ -290,6 +290,12 @@ func Discover(path string) []Suite { }) } + // If we still could not find any coherent test suite, just add the + // current directory in the hopes it contains TTCN-3 files. + if len(list) == 0 { + return []Suite{{RootDir: path, SourceDir: path}} + } + // Remove duplicate entries result := make([]Suite, 0, len(list)) visited := make(map[Suite]bool)