Skip to content

Commit

Permalink
gopls/internal/regtest: add a failing test for swig
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stamblerre committed Oct 13, 2020
1 parent 5bd0538 commit ec925d8
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
45 changes: 45 additions & 0 deletions gopls/internal/regtest/diagnostics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '#'"),
),
)
})
}
27 changes: 27 additions & 0 deletions gopls/internal/regtest/expectation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
}

0 comments on commit ec925d8

Please sign in to comment.