From 2c7930d2947b6c1cfebc3db3bd54ed079e0dcb7c Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Sun, 9 Aug 2015 09:25:59 -0500 Subject: [PATCH 1/8] long standing PR in the hopes one day windows builds work --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index f81774d..4cd9293 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,6 +55,7 @@ install: - echo %GOPATH% - dir C:\mingw64\bin - go get golang.org/x/net/context + - go test build_script: - go build -x -ldflags "-extldflags '-static'" From 557bd13960380b23442d76bf1a357b37359a1cb1 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Sat, 19 Dec 2015 23:37:20 -0600 Subject: [PATCH 2/8] use external static linker --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4cd9293..a2e834b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -53,9 +53,9 @@ install: - set CXX=g++ - echo %PATH% - echo %GOPATH% - - dir C:\mingw64\bin + - # dir C:\mingw64\bin - go get golang.org/x/net/context - - go test + - go test -x -v -ldflags "-extldflags '-static'" build_script: - go build -x -ldflags "-extldflags '-static'" From 8b0116ff16d086a4717d1794b3d56e0b87244f83 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Tue, 22 Dec 2015 12:31:00 -0600 Subject: [PATCH 3/8] don't build these tests on windows --- error_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/error_test.go b/error_test.go index 5c96eee..69c4892 100644 --- a/error_test.go +++ b/error_test.go @@ -1,3 +1,4 @@ +// +build !windows package libsass import ( From e42c9713ce6a8ef9755ef48b1c1c4844b07535cb Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Tue, 22 Dec 2015 12:38:41 -0600 Subject: [PATCH 4/8] overload short for use with windows testing --- circle.yml | 2 +- context_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index c582bdd..d478a0c 100644 --- a/circle.yml +++ b/circle.yml @@ -25,4 +25,4 @@ dependencies: - go test -i -race $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/) test: override: - - go test -race $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/) + - go test -short -race $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/) diff --git a/context_test.go b/context_test.go index c1dd398..42acbcf 100644 --- a/context_test.go +++ b/context_test.go @@ -99,6 +99,11 @@ div { } func TestLibsassError(t *testing.T) { + + if testing.Short() { + t.Skip("Skip error testing on windows") + } + in := bytes.NewBufferString(`div { color: red(blue, purple); }`) From 93b0cb2806d7b12ae27b7ca9bd234c9f34df023e Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Tue, 22 Dec 2015 12:52:33 -0600 Subject: [PATCH 5/8] umm short doesnt work on windows --- circle.yml | 2 +- context_nowin_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ context_test.go | 38 -------------------------------------- 3 files changed, 42 insertions(+), 39 deletions(-) create mode 100644 context_nowin_test.go diff --git a/circle.yml b/circle.yml index d478a0c..463d22e 100644 --- a/circle.yml +++ b/circle.yml @@ -25,4 +25,4 @@ dependencies: - go test -i -race $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/) test: override: - - go test -short -race $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/) + - go test -v -short -race $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/) diff --git a/context_nowin_test.go b/context_nowin_test.go new file mode 100644 index 0000000..2bcd981 --- /dev/null +++ b/context_nowin_test.go @@ -0,0 +1,41 @@ +// +build !windows +package libsass + +import ( + "bytes" + "testing" +) + +func TestLibsassError(t *testing.T) { + + in := bytes.NewBufferString(`div { + color: red(blue, purple); +}`) + + var out bytes.Buffer + ctx := NewContext() + + ctx.Funcs.Add(Func{ + Sign: "foo()", + Fn: TestCallback, + Ctx: &ctx, + }) + err := ctx.Compile(in, &out) + + if err == nil { + t.Error("No error thrown for incorrect arity") + } + + if e := "wrong number of arguments (2 for 1) for `red'"; e != ctx.err.Message { + t.Errorf("wanted:%s\ngot:%s\n", e, ctx.err.Message) + } + e := `Error > stdin:2 +wrong number of arguments (2 for 1) for ` + "`" + `red' +div { + color: red(blue, purple); +} +` + if e != err.Error() { + t.Errorf("wanted:\n%s\ngot:\n%s\n", e, err) + } +} diff --git a/context_test.go b/context_test.go index 42acbcf..b93b57f 100644 --- a/context_test.go +++ b/context_test.go @@ -98,44 +98,6 @@ div { } -func TestLibsassError(t *testing.T) { - - if testing.Short() { - t.Skip("Skip error testing on windows") - } - - in := bytes.NewBufferString(`div { - color: red(blue, purple); -}`) - - var out bytes.Buffer - ctx := NewContext() - - ctx.Funcs.Add(Func{ - Sign: "foo()", - Fn: TestCallback, - Ctx: &ctx, - }) - err := ctx.Compile(in, &out) - - if err == nil { - t.Error("No error thrown for incorrect arity") - } - - if e := "wrong number of arguments (2 for 1) for `red'"; e != ctx.err.Message { - t.Errorf("wanted:%s\ngot:%s\n", e, ctx.err.Message) - } - e := `Error > stdin:2 -wrong number of arguments (2 for 1) for ` + "`" + `red' -div { - color: red(blue, purple); -} -` - if e != err.Error() { - t.Errorf("wanted:\n%s\ngot:\n%s\n", e, err) - } -} - func ExampleContext_Compile() { in := bytes.NewBufferString(`div { color: red(blue); From 8c5b36edff1b2799712b12393419b5d66f485d89 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Fri, 22 Jan 2016 09:02:20 -0600 Subject: [PATCH 6/8] take reponsibility for freeing error memory --- libs/wrap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wrap.go b/libs/wrap.go index fd82d16..4e514c6 100644 --- a/libs/wrap.go +++ b/libs/wrap.go @@ -242,7 +242,7 @@ func SassContextGetOutputString(goctx SassContext) string { // SassContextGetErrorJSON requests an error in JSON format from libsass func SassContextGetErrorJSON(goctx SassContext) string { - cstr := C.sass_context_get_error_json(goctx) + cstr := C.sass_context_take_error_json(goctx) defer C.free(unsafe.Pointer(cstr)) return C.GoString(cstr) } From 96751b201b43fb03704cf50f10fb8c0713fe8293 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Fri, 22 Jan 2016 09:12:44 -0600 Subject: [PATCH 7/8] stupid is as stupid does --- libs/wrap.go | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/wrap.go b/libs/wrap.go index 4e514c6..327529f 100644 --- a/libs/wrap.go +++ b/libs/wrap.go @@ -244,6 +244,7 @@ func SassContextGetOutputString(goctx SassContext) string { func SassContextGetErrorJSON(goctx SassContext) string { cstr := C.sass_context_take_error_json(goctx) defer C.free(unsafe.Pointer(cstr)) + fmt.Println("Error text yo!", C.GoString(cstr)) return C.GoString(cstr) } From 7e06974a783722e8b53d987e73028edb1814ceec Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Fri, 22 Jan 2016 09:40:41 -0600 Subject: [PATCH 8/8] just remove this line? --- libsass-build/sass_context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsass-build/sass_context.cpp b/libsass-build/sass_context.cpp index 32e6b83..ced22ef 100644 --- a/libsass-build/sass_context.cpp +++ b/libsass-build/sass_context.cpp @@ -444,8 +444,8 @@ extern "C" { if (compiler->state != SASS_COMPILER_CREATED) return -1; if (compiler->c_ctx == NULL) return 1; if (compiler->cpp_ctx == NULL) return 1; - if (compiler->c_ctx->error_status) - return compiler->c_ctx->error_status; + // if (compiler->c_ctx->error_status) + // return compiler->c_ctx->error_status; // parse the context we have set up (file or data) compiler->root = sass_parse_block(compiler); // success