nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: go-delve/delve
Pull request #2420 (2021-04-07 20:15:41)

dap: suppress error popup for failed evaluation request in repl mode
It's expected that users enter invalid expressions through DEBUG
CONSOLE. Pop up for every error is not pleasant.

polinasok: Opps, rashed to approved without realizing that tests did not get updated and are now failing.
hyangah: Thanks!

Patch:
diff --git a/service/dap/server.go b/service/dap/server.go
index 39e74a82..664944d4 100644
--- a/service/dap/server.go
+++ b/service/dap/server.go
@@ -1272,7 +1272,7 @@ func (s *Server) convertVariableWithOpts(v *proc.Variable, qualifiedNameOrExpr s
 // variables, so consider also adding the following:
 // -- print {expression} - return the result as a string like from dlv cli
 func (s *Server) onEvaluateRequest(request *dap.EvaluateRequest) {
-	showErrorToUser := request.Arguments.Context != "watch"
+	showErrorToUser := request.Arguments.Context != "watch" && request.Arguments.Context != "repl"
 	if s.debugger == nil {
 		s.sendErrorResponseWithOpts(request.Request, UnableToEvaluateExpression, "Unable to evaluate expression", "debugger is nil", showErrorToUser)
 		return


Test patch:
diff --git a/service/dap/server_test.go b/service/dap/server_test.go
index 73cd7e4b..7c5e3265 100644
--- a/service/dap/server_test.go
+++ b/service/dap/server_test.go
@@ -197,7 +197,7 @@ func TestLaunchStopOnEntry(t *testing.T) {
 
 		// 10 >> evaluate, << error
 		client.EvaluateRequest("foo", 0 /*no frame specified*/, "repl")
-		erResp := client.ExpectVisibleErrorResponse(t)
+		erResp := client.ExpectErrorResponse(t)
 		if erResp.Seq != 0 || erResp.RequestSeq != 10 || erResp.Body.Error.Id != 2009 {
 			t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=10 Id=2009", erResp)
 		}
@@ -323,7 +323,7 @@ func TestAttachStopOnEntry(t *testing.T) {
 
 		// 10 >> evaluate, << error
 		client.EvaluateRequest("foo", 0 /*no frame specified*/, "repl")
-		erResp := client.ExpectVisibleErrorResponse(t)
+		erResp := client.ExpectErrorResponse(t)
 		if erResp.Seq != 0 || erResp.RequestSeq != 10 || erResp.Body.Error.Id != 2009 {
 			t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=10 Id=2009", erResp)
 		}
Repository: go-bdd/gobdd
Pull request #44 (2019-09-29 20:13:31)

Add check if the step func is in correct format


Patch:
diff --git a/gobdd.go b/gobdd.go
index 86f9906..29f74e6 100644
--- a/gobdd.go
+++ b/gobdd.go
@@ -104,6 +104,10 @@ func NewSuite(t *testing.T, options SuiteOptions) *Suite {
 // The second parameter is a function which will be executed when while running a scenario one of the steps will match
 // the given pattern
 func (s *Suite) AddStep(step interface{}, f interface{}) error {
+	err := validateStepFunc(f)
+	if err != nil {
+	    return err
+	}
 	var regex *regexp.Regexp
 
 	switch t := step.(type) {
diff --git a/steps.go b/steps.go
new file mode 100644
index 0000000..a1d5e56
--- /dev/null
+++ b/steps.go
@@ -0,0 +1,34 @@
+package gobdd
+
+import (
+	"errors"
+	"github.com/go-bdd/gobdd/context"
+	"reflect"
+)
+
+func validateStepFunc(f interface{}) error {
+	value := reflect.ValueOf(f)
+	if value.Kind() != reflect.Func {
+		return errors.New("the parameter should be a function")
+	}
+
+	if value.Type().NumOut() != 1 {
+		return errors.New("the function should return only error")
+	}
+	val := value.Type().Out(0)
+	errorInterface  := reflect.TypeOf((*error)(nil)).Elem()
+	if !val.Implements(errorInterface) {
+		return errors.New("the returned value should implement the Error interface")
+	}
+
+	if value.Type().NumIn() < 1 {
+		return errors.New("the function should have Context as the first argument")
+	}
+
+	val = value.Type().In(0)
+	n := val.ConvertibleTo(reflect.ValueOf(context.Context{}).Type())
+	if !n {
+		return errors.New("the returned value should implement the Error interface")
+	}
+	return nil
+}


Test patch:
diff --git a/gobdd_test.go b/gobdd_test.go
index 2a5f54d..762e905 100644
--- a/gobdd_test.go
+++ b/gobdd_test.go
@@ -81,6 +81,27 @@ func TestIgnoredTags(t *testing.T) {
 	suite.Run()
 }
 
+func TestInvalidFunctionSignature(t *testing.T) {
+	testCases := map[string]struct{
+		f interface{}
+	}{
+		"nil": {},
+		"func without return value": {f: func(ctx context.Context) {}},
+		"func with invalid return value": {f: func(ctx context.Context) int { return 0}},
+		"func without arguments": {f: func() error { return errors.New("")}},
+		"func with invalid first argument": {f: func(i int) error { return errors.New("")}},
+	}
+
+	for name, testCase := range testCases {
+		t.Run(name, func(t *testing.T) {
+			suite := NewSuite(t, NewSuiteOptions())
+			err := suite.AddStep("", testCase.f)
+			if err == nil {
+				t.Errorf("the function has invalid signature; the test should fail")
+			}
+		})
+	}
+}
 
 func add(ctx context.Context, var1, var2 int) error {
 	res := var1 + var2
Repository: go-bdd/gobdd
Pull request #69 (2020-02-11 08:27:46)

Add GetError to the context
Fixes https://github.com/go-bdd/gobdd/issues/55
FYI @sagikazarmark 


Patch:
diff --git a/context/context.go b/context/context.go
index e17826e..b93f5c4 100644
--- a/context/context.go
+++ b/context/context.go
@@ -34,3 +34,19 @@ func (ctx Context) Get(key interface{}, defaultValue ...interface{}) interface{}
 
 	return ctx.values[key]
 }
+
+
+func (ctx Context) GetError(key interface{}, defaultValue ...interface{}) interface{} {
+	if _, ok := ctx.values[key]; !ok {
+		if len(defaultValue) == 1 {
+			return defaultValue[0]
+		}
+		panic(fmt.Sprintf("the key %+v does not exist", key))
+	}
+
+	value, ok := ctx.values[key].(error)
+	if !ok {
+		panic(fmt.Sprintf("the expected value is not error  (%T)", key))
+	}
+	return value
+}
diff --git a/gen/ctxgen.go b/gen/ctxgen.go
index 5646de3..c26dd54 100644
--- a/gen/ctxgen.go
+++ b/gen/ctxgen.go
@@ -92,6 +92,18 @@ var testTmpl = `// Code generated .* DO NOT EDIT.
 package context
 
 import "testing"
+import "errors"
+
+func TestContext_GetError(t *testing.T) {
+	ctx := New()
+	expected := errors.New("new err")
+	ctx.Set("test", expected)
+	received := ctx.GetError("test")
+	if received != expected {
+		t.Errorf("expected %+v but received %+v", expected, received)
+	}
+}
+
 {{ range .Types }}
 func TestContext_Get{{ .Name | Title }}(t *testing.T) {
 	ctx := New()
@@ -138,6 +150,7 @@ var getTmpl = `// Code generated .* DO NOT EDIT.
 package context
 
 import "fmt"
+
 {{ range .Types }}
 func (ctx Context) Get{{ .Name | Title }}(key interface{}, defaultValue ...{{ .Name }}) {{ .Name }} {
 	if len(defaultValue) > 1 {


Test patch:
diff --git a/context/get_test.go b/context/get_test.go
index 2bf9a54..37f591e 100644
--- a/context/get_test.go
+++ b/context/get_test.go
@@ -2,6 +2,18 @@
 package context
 
 import "testing"
+import "errors"
+
+func TestContext_GetError(t *testing.T) {
+	ctx := New()
+	expected := errors.New("new err")
+	ctx.Set("test", expected)
+	received := ctx.GetError("test")
+	if received != expected {
+		t.Errorf("expected %+v but received %+v", expected, received)
+	}
+}
+
 
 func TestContext_GetString(t *testing.T) {
 	ctx := New()
Repository: go-bdd/gobdd
Pull request #102 (2020-05-19 19:07:05)

add tests for WithAfterScenario and WithBeforeScenario


Patch:
diff --git a/features/empty.feature b/features/empty.feature
new file mode 100644
index 0000000..3cbf9a3
--- /dev/null
+++ b/features/empty.feature
@@ -0,0 +1,2 @@
+Feature: empty
+  Scenario: empty
\ No newline at end of file


Test patch:
diff --git a/gobdd_test.go b/gobdd_test.go
index 485ef87..a8645c9 100644
--- a/gobdd_test.go
+++ b/gobdd_test.go
@@ -60,6 +60,30 @@ func TestTags(t *testing.T) {
 	suite.Run()
 }
 
+func TestWithAfterScenario(t *testing.T) {
+	c := false
+	suite := NewSuite(t, WithFeaturesPath("features/empty.feature"), WithAfterScenario(func(ctx context.Context) {
+		c = true
+	}))
+	suite.Run()
+
+	if err := assert.Equals(true, c); err != nil {
+		t.Error(err)
+	}
+}
+
+func TestWithBeforeScenario(t *testing.T) {
+	c := false
+	suite := NewSuite(t, WithFeaturesPath("features/empty.feature"), WithBeforeScenario(func(ctx context.Context) {
+		c = true
+	}))
+	suite.Run()
+
+	if err := assert.Equals(true, c); err != nil {
+		t.Error(err)
+	}
+}
+
 func TestIgnoredTags(t *testing.T) {
 	suite := NewSuite(t, WithFeaturesPath("features/ignored_tags.feature"), WithIgnoredTags([]string{"@ignore"}))
 	suite.AddStep(`fail the test`, fail)
Repository: go-bdd/gobdd
Pull request #132 (2021-04-16 10:28:40)

Use both feature and scenario tags in skipScenario
Currently the feature tags are not taken into account when determining if a scenario should be executed or not.

This should allow positive filtering which is different from skip.

bkielbasa: thanks for your submission! Could you add a test for it as well?
jirikuncar: It seems like it should work thanks to https://github.com/go-bdd/gobdd/blob/master/gobdd.go#L302-L307. I will investigate more why it was failing for me.
jirikuncar: @bkielbasa I have added new test scenarios.
bkielbasa: thanks for your PR, merging :) 

Patch:
diff --git a/features/filter_tags_negative.feature b/features/filter_tags_negative.feature
new file mode 100644
index 0000000..b77b37e
--- /dev/null
+++ b/features/filter_tags_negative.feature
@@ -0,0 +1,3 @@
+Feature: do not run this
+  Scenario: the scenario should not executed
+    Then fail the test
\ No newline at end of file
diff --git a/features/filter_tags_positive.feature b/features/filter_tags_positive.feature
new file mode 100644
index 0000000..5addb97
--- /dev/null
+++ b/features/filter_tags_positive.feature
@@ -0,0 +1,4 @@
+@run-this
+Feature: run this
+  Scenario: the scenario should executed
+    Then the test should pass
\ No newline at end of file
diff --git a/gobdd.go b/gobdd.go
index 33a6b68..d3cee26 100644
--- a/gobdd.go
+++ b/gobdd.go
@@ -321,7 +321,7 @@ func (s *Suite) runFeature(feature *msgs.GherkinDocument_Feature) error {
 				continue
 			}
 
-			if s.skipScenario(scenario.GetTags()) {
+			if s.skipScenario(append(feature.GetTags(), scenario.GetTags()...)) {
 				t.Log(fmt.Sprintf("Skipping scenario %s", scenario.Name))
 				continue
 			}


Test patch:
diff --git a/gobdd_test.go b/gobdd_test.go
index e8a23d2..9c373a0 100644
--- a/gobdd_test.go
+++ b/gobdd_test.go
@@ -118,6 +118,22 @@ func TestTags(t *testing.T) {
 	suite.Run()
 }
 
+func TestFilterFeatureWithTags(t *testing.T) {
+	suite := NewSuite(t, WithFeaturesPath("features/filter_tags_*.feature"), WithTags([]string{"@run-this"}))
+	c := false
+
+	suite.AddStep(`the test should pass`, func(_ StepTest, _ Context) {
+		c = true
+	})
+	suite.AddStep(`fail the test`, fail)
+
+	suite.Run()
+
+	if err := assert.Equals(true, c); err != nil {
+		t.Error(err)
+	}
+}
+
 func TestWithAfterScenario(t *testing.T) {
 	c := false
 	suite := NewSuite(t, WithFeaturesPath("features/empty.feature"), WithAfterScenario(func(ctx Context) {
@@ -183,6 +199,7 @@ func TestIgnorFeatureWithTags(t *testing.T) {
 	suite.AddStep(`fail the test`, fail)
 	suite.Run()
 }
+
 func TestInvalidFunctionSignature(t *testing.T) {
 	testCases := map[string]struct {
 		f interface{}
Repository: go-acme/lego
Pull request #2029 (2023-10-06 22:52:11)

gandiv5: Add "Bearer" prefix to the auth header
The "Bearer" prefix is required per
https://api.gandi.net/docs/authentication/ to declare the content of the Authorization header as a personal access token.

Without this change, the user has to specify `GANDIV5_PERSONAL_ACCESS_TOKEN='Bearer 12341234'` instead of `GANDIV5_PERSONAL_ACCESS_TOKEN=12341234` which disagrees with the documentation and the existing test data.

This change is not backwards-compatible. This should be OK because the commit 113648a36817a5d9667b8dd1f1c6c67eeb914916 (#2007) which added support for personal access tokens was not in any release yet.


Patch:
diff --git a/providers/dns/gandiv5/internal/client.go b/providers/dns/gandiv5/internal/client.go
index d91c1422..57de9d61 100644
--- a/providers/dns/gandiv5/internal/client.go
+++ b/providers/dns/gandiv5/internal/client.go
@@ -134,7 +134,7 @@ func (c *Client) do(req *http.Request, result any) error {
 	}
 
 	if c.pat != "" {
-		req.Header.Set(authorizationHeader, c.pat)
+		req.Header.Set(authorizationHeader, "Bearer "+c.pat)
 	}
 
 	resp, err := c.HTTPClient.Do(req)


Test patch:
diff --git a/providers/dns/gandiv5/gandiv5_test.go b/providers/dns/gandiv5/gandiv5_test.go
index 2cc8f1cd..57fed032 100644
--- a/providers/dns/gandiv5/gandiv5_test.go
+++ b/providers/dns/gandiv5/gandiv5_test.go
@@ -121,8 +121,8 @@ func TestDNSProvider(t *testing.T) {
 	mux.HandleFunc("/domains/example.com/records/_acme-challenge.abc.def/TXT", func(rw http.ResponseWriter, req *http.Request) {
 		log.Infof("request: %s %s", req.Method, req.URL)
 
-		if req.Header.Get("Authorization") == "" {
-			http.Error(rw, `{"message": "missing Authorization"}`, http.StatusUnauthorized)
+		if req.Header.Get("Authorization") != "Bearer 123412341234123412341234" {
+			http.Error(rw, `{"message": "missing or malformed Authorization"}`, http.StatusUnauthorized)
 			return
 		}