Skip to content

Commit 2af6148

Browse files
author
Federico Fissore
committed
Windows doesn't like "patch"
Signed-off-by: Federico Fissore <[email protected]>
1 parent c90dedf commit 2af6148

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Once done, run the following commands:
6363
go get github.com/go-errors/errors
6464
go get github.com/stretchr/testify
6565
go get github.com/jstemmer/go-junit-report
66+
go get golang.org/x/codereview/patch
6667
go build
6768
```
6869

src/arduino.cc/builder/test/downloaded_stuff_patches/avr_platform_patch.patch

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
--- downloaded_hardware/arduino/avr/platform.txt 2015-09-10 17:14:15.137942087 +0200
2-
+++ downloaded_hardware/arduino/avr/platform.txt 2015-09-23 10:27:19.522085331 +0200
3-
@@ -77,6 +77,12 @@
1+
diff --git a/downloaded_hardware/arduino/avr/platform.txt b/downloaded_hardware/arduino/avr/platform.txt
2+
index 537fcc5..4e526d9 100644
3+
--- a/downloaded_hardware/arduino/avr/platform.txt
4+
+++ b/downloaded_hardware/arduino/avr/platform.txt
5+
@@ -81,6 +81,12 @@ recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
46
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
57
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
68

src/arduino.cc/builder/test/downloaded_stuff_patches/hid_library_properties.patch.disabled

-8
This file was deleted.

src/arduino.cc/builder/test/helper_tools_downloader.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"encoding/json"
3838
"fmt"
3939
"github.com/go-errors/errors"
40+
"golang.org/x/codereview/patch"
4041
"io"
4142
"io/ioutil"
4243
"net/http"
@@ -133,20 +134,24 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) {
133134

134135
download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, boardsManagerTools, boardsManagerRFduinoTools, libraries)
135136

136-
patch(t)
137+
patchFiles(t)
137138
}
138139

139140
// FIXME: once patched cores are released, patching them will be unnecessary
140-
func patch(t *testing.T) {
141+
func patchFiles(t *testing.T) {
141142
files, err := ioutil.ReadDir(PATCHES_FOLDER)
142143
NoError(t, err)
143144

144145
for _, file := range files {
145146
if filepath.Ext(file.Name()) == ".patch" {
146-
cmd := exec.Command("patch", "-N", "-p0", "-r", "-", "-i", filepath.Join(PATCHES_FOLDER, file.Name()))
147-
cmd.CombinedOutput()
148-
//output, _ := cmd.CombinedOutput()
149-
//fmt.Println(string(output))
147+
data, err := ioutil.ReadFile(Abs(t, filepath.Join(PATCHES_FOLDER, file.Name())))
148+
NoError(t, err)
149+
patchSet, err := patch.Parse(data)
150+
NoError(t, err)
151+
operations, err := patchSet.Apply(ioutil.ReadFile)
152+
for _, op := range operations {
153+
ioutil.WriteFile(op.Dst, op.Data, os.FileMode(0644))
154+
}
150155
}
151156
}
152157
}

0 commit comments

Comments
 (0)