nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pingcap/tidb-lightning
Pull request #209 (2019-07-13 10:13:43)

tests,web: exclude these directories from the Go module
<!--
Thank you for contributing to TiDB-Lightning! Please read the [CONTRIBUTING](https://github.com/pingcap/tidb-lightning/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.
-->

### What problem does this PR solve? <!--add issue link with summary if exists-->

Currently when trying to import tidb-lightning externally on macOS we'll get a "malformed file path" error due to a `` ` `` in the filename of a test case. Since a Go module shouldn't need the integrated tests anyway, we just ignore these non-source folders instead of trying to fix Go 🤷.

### What is changed and how it works?

Recommended in https://github.com/golang/go/wiki/Modules#can-an-additional-gomod-exclude-unnecessary-content-do-modules-have-the-equivalent-of-a-gitignore-file, we include an empty `go.mod` in the `tests/` and `web/` folder so they're no longer part of the Go module.

### Check List <!--REMOVE the items that are not applicable-->

Tests <!-- At least one of them must be included. -->

 - No code

Side effects

Related changes


kennytm: /run-all-tests 

kennytm: PTAL @csuzhangxc @lance6716 
lance6716: LGTM

Patch:
diff --git a/web/go.mod b/web/go.mod
new file mode 100644
index 0000000..7fdc6d9
--- /dev/null
+++ b/web/go.mod
@@ -0,0 +1,1 @@
+// Exclude this directory from the Go module


Test patch:
diff --git a/tests/go.mod b/tests/go.mod
new file mode 100644
index 0000000..7fdc6d9
--- /dev/null
+++ b/tests/go.mod
@@ -0,0 +1,1 @@
+// Exclude this directory from the Go module
Repository: pingcap/tidb-lightning
Pull request #239 (2019-09-06 08:37:29)

[2.1]checkpoint: fix empty map become nil after unmarshall (#237)
<!--
Thank you for contributing to TiDB-Lightning! Please read the [CONTRIBUTING](https://github.com/pingcap/tidb-lightning/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.
-->

### What problem does this PR solve? <!--add issue link with summary if exists-->
cherry-pick for #237

### What is changed and how it works?


### Check List <!--REMOVE the items that are not applicable-->

Tests <!-- At least one of them must be included. -->

 - Unit test

Side effects

Related changes


lance6716: /run-all-tests tidb=release-2.1 pd=release-2.1 tikv=release-2.1
lance6716: PTAL @kennytm @GregoryIan

Patch:
diff --git a/lightning/restore/checkpoints.go b/lightning/restore/checkpoints.go
index c4aadf6..627aa36 100644
--- a/lightning/restore/checkpoints.go
+++ b/lightning/restore/checkpoints.go
@@ -654,7 +654,25 @@ func NewFileCheckpointsDB(path string) *FileCheckpointsDB {
 	// ignore all errors -- file maybe not created yet (and it is fine).
 	content, err := ioutil.ReadFile(path)
 	if err == nil {
-		cpdb.checkpoints.Unmarshal(content)
+		err2 := cpdb.checkpoints.Unmarshal(content)
+		if err2 != nil {
+			common.AppLogger.Errorf("checkpoint file is broken %s, error: %v", path, err)
+		}
+		// FIXME: patch for empty map may need initialize manually, because currently
+		// FIXME: a map of zero size -> marshall -> unmarshall -> become nil, see checkpoint_test.go
+		if cpdb.checkpoints.Checkpoints == nil {
+			cpdb.checkpoints.Checkpoints = map[string]*TableCheckpointModel{}
+		}
+		for _, table := range cpdb.checkpoints.Checkpoints {
+			if table.Engines == nil {
+				table.Engines = map[int32]*EngineCheckpointModel{}
+			}
+			for _, engine := range table.Engines {
+				if engine.Chunks == nil {
+					engine.Chunks = map[string]*ChunkCheckpointModel{}
+				}
+			}
+		}
 	} else {
 		common.AppLogger.Warnf("failed to open checkpoint file %s, going to create a new one: %v", path, err)
 	}


Test patch:
diff --git a/lightning/restore/checkpoint_test.go b/lightning/restore/checkpoint_test.go
new file mode 100644
index 0000000..0288613
--- /dev/null
+++ b/lightning/restore/checkpoint_test.go
@@ -0,0 +1,24 @@
+package restore
+
+import (
+	. "github.com/pingcap/check"
+	"path/filepath"
+)
+
+var _ = Suite(&checkpointSuite{})
+
+type checkpointSuite struct{}
+
+func (s *splitKVSuite) TestCheckpointMarshallUnmarshall(c *C) {
+	path := filepath.Join(c.MkDir(), "filecheckpoint")
+	fileChkp := NewFileCheckpointsDB(path)
+	fileChkp.checkpoints.Checkpoints["a"] = &TableCheckpointModel{
+		Status:  uint32(CheckpointStatusLoaded),
+		Engines: map[int32]*EngineCheckpointModel{},
+	}
+	fileChkp.Close()
+
+	fileChkp2 := NewFileCheckpointsDB(path)
+	// if not recover empty map explicitly, it will become nil
+	c.Assert(fileChkp2.checkpoints.Checkpoints["a"].Engines, NotNil)
+}
\ No newline at end of file