From 44ba56e3977d215eceb6ac9e770d1a7540463ad8 Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Tue, 11 Feb 2020 06:50:05 +0000 Subject: [PATCH] cmd/govim: add a test that verifies things generally work for cgo (#429) Pending golang.org/issues/35721, this test is skipped. --- .../testdata/scenario_default/cgo_support.txt | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 cmd/govim/testdata/scenario_default/cgo_support.txt diff --git a/cmd/govim/testdata/scenario_default/cgo_support.txt b/cmd/govim/testdata/scenario_default/cgo_support.txt new file mode 100644 index 000000000..492e2b897 --- /dev/null +++ b/cmd/govim/testdata/scenario_default/cgo_support.txt @@ -0,0 +1,66 @@ +# Test that things generally work for packages/files that import "C" + +[golang.org/issues/35721] skip + +# Check that everything builds +go test + +# Check that we can do stuff in the file that does not import "C" +vim ex 'e '$WORK/p_noimportc.go +vim ex 'call cursor(3,15)' +vim ex 'GOVIMGoToDef' +vim expr 'bufname(\"\")' +stdout '^\Q"'$WORK'/p_noimportc.go"\E$' +vim expr '[getcurpos()[1], getcurpos()[2]]' +stdout '^\Q[5,7]\E$' + +# Check that we can do stuff in the file that DOES import "C" +vim ex 'e '$WORK/p_importc.go +vim ex 'call cursor(17,15)' +vim ex 'GOVIMGoToDef' +vim expr 'bufname(\"\")' +stdout '^\Q"'$WORK'/p_importc.go"\E$' +vim expr '[getcurpos()[1], getcurpos()[2]]' +stdout '^\Q[5,7]\E$' + +# Assert that we have received no error (Type: 1) or warning (Type: 2) log messages +# Disabled pending resolution to https://github.com/golang/go/issues/34103 +# errlogmatch -start -count=0 'LogMessage callback: &protocol\.LogMessageParams\{Type:(1|2), Message:".*' + +-- go.mod -- +module mod.com/p + +go1.12 +-- p_importc.go -- +package p + +/* +#include +#include + +void myprint(char* s) { + printf("%s\n", s); +} +*/ +import "C" + +import "fmt" + +import "unsafe" + +const Name1 = SameFile1 + +const SameFile1 = "samefile" + +func Example() { +fmt.Println() + cs := C.CString("Hello from stdio\n") + C.myprint(cs) + C.free(unsafe.Pointer(cs)) +} +-- p_noimportc.go -- +package p + +const Name2 = SameFile2 + +const SameFile2 = "samefile"