mirror of https://github.com/golang/go.git
gopls/internal/regtest: add a failing test for swig
Fixes golang/go#37660 Change-Id: I4607142af03224820e8350a85eca722586b150b5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/261140 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
5bd0538631
commit
ec925d8b1d
|
|
@ -1382,3 +1382,48 @@ func main() {
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSwig(t *testing.T) {
|
||||
t.Skipf("skipped until golang/go#37098 is resolved")
|
||||
|
||||
const mod = `
|
||||
-- go.mod --
|
||||
module mod.com
|
||||
-- pkg/simple/export_swig.go --
|
||||
package simple
|
||||
|
||||
func ExportSimple(x, y int) int {
|
||||
return Gcd(x, y)
|
||||
}
|
||||
-- pkg/simple/simple.swigcxx --
|
||||
%module simple
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y)
|
||||
{
|
||||
int g;
|
||||
g = y;
|
||||
while (x > 0) {
|
||||
g = x;
|
||||
x = y % x;
|
||||
y = g;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
%}
|
||||
-- main.go --
|
||||
package a
|
||||
|
||||
func main() {
|
||||
var x int
|
||||
}
|
||||
`
|
||||
run(t, mod, func(t *testing.T, env *Env) {
|
||||
env.Await(
|
||||
OnceMet(
|
||||
InitialWorkspaceLoad,
|
||||
NoDiagnosticWithMessage("illegal character U+0023 '#'"),
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"golang.org/x/tools/internal/lsp"
|
||||
"golang.org/x/tools/internal/lsp/protocol"
|
||||
"golang.org/x/tools/internal/span"
|
||||
)
|
||||
|
||||
// An Expectation asserts that the state of the editor at a point in time
|
||||
|
|
@ -491,3 +492,29 @@ func NoDiagnosticAt(name string, line, col int) DiagnosticExpectation {
|
|||
path: name,
|
||||
}
|
||||
}
|
||||
|
||||
// NoDiagnosticWithMessage asserts that there is no diagnostic entry with the
|
||||
// given message.
|
||||
//
|
||||
// This should only be used in combination with OnceMet for a given condition,
|
||||
// otherwise it may always succeed.
|
||||
func NoDiagnosticWithMessage(msg string) DiagnosticExpectation {
|
||||
var uri span.URI
|
||||
isMet := func(diags *protocol.PublishDiagnosticsParams) bool {
|
||||
for _, d := range diags.Diagnostics {
|
||||
if d.Message == msg {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
var path string
|
||||
if uri != "" {
|
||||
path = uri.Filename()
|
||||
}
|
||||
return DiagnosticExpectation{
|
||||
isMet: isMet,
|
||||
description: fmt.Sprintf("no diagnostic with message %s", msg),
|
||||
path: path,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue