From 2af61484ec15fe39481a7ebe73c0d49ba45526a3 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 28 Sep 2015 17:06:55 +0200 Subject: [PATCH] Windows doesn't like "patch" Signed-off-by: Federico Fissore --- README.md | 1 + .../avr_platform_patch.patch | 8 +++++--- .../hid_library_properties.patch.disabled | 8 -------- .../builder/test/helper_tools_downloader.go | 17 +++++++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 src/arduino.cc/builder/test/downloaded_stuff_patches/hid_library_properties.patch.disabled diff --git a/README.md b/README.md index fd3b16aa..cd2759d5 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Once done, run the following commands: go get github.com/go-errors/errors go get github.com/stretchr/testify go get github.com/jstemmer/go-junit-report +go get golang.org/x/codereview/patch go build ``` diff --git a/src/arduino.cc/builder/test/downloaded_stuff_patches/avr_platform_patch.patch b/src/arduino.cc/builder/test/downloaded_stuff_patches/avr_platform_patch.patch index 5df808be..57e3f495 100644 --- a/src/arduino.cc/builder/test/downloaded_stuff_patches/avr_platform_patch.patch +++ b/src/arduino.cc/builder/test/downloaded_stuff_patches/avr_platform_patch.patch @@ -1,6 +1,8 @@ ---- downloaded_hardware/arduino/avr/platform.txt 2015-09-10 17:14:15.137942087 +0200 -+++ downloaded_hardware/arduino/avr/platform.txt 2015-09-23 10:27:19.522085331 +0200 -@@ -77,6 +77,12 @@ +diff --git a/downloaded_hardware/arduino/avr/platform.txt b/downloaded_hardware/arduino/avr/platform.txt +index 537fcc5..4e526d9 100644 +--- a/downloaded_hardware/arduino/avr/platform.txt ++++ b/downloaded_hardware/arduino/avr/platform.txt +@@ -81,6 +81,12 @@ recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).* recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).* recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).* diff --git a/src/arduino.cc/builder/test/downloaded_stuff_patches/hid_library_properties.patch.disabled b/src/arduino.cc/builder/test/downloaded_stuff_patches/hid_library_properties.patch.disabled deleted file mode 100644 index 934c3d58..00000000 --- a/src/arduino.cc/builder/test/downloaded_stuff_patches/hid_library_properties.patch.disabled +++ /dev/null @@ -1,8 +0,0 @@ ---- downloaded_libraries/HID/library.properties 2015-09-23 09:49:20.470004391 +0200 -+++ downloaded_libraries/HID/library.properties.new 2015-09-23 11:04:13.206163949 +0200 -@@ -7,4 +7,4 @@ - category=Device Control - url=https://github.com/NicoHood/HID - architectures=* --alinkage=true -+dot_a_linkage=true diff --git a/src/arduino.cc/builder/test/helper_tools_downloader.go b/src/arduino.cc/builder/test/helper_tools_downloader.go index 530f7f4b..013d5de8 100644 --- a/src/arduino.cc/builder/test/helper_tools_downloader.go +++ b/src/arduino.cc/builder/test/helper_tools_downloader.go @@ -37,6 +37,7 @@ import ( "encoding/json" "fmt" "github.com/go-errors/errors" + "golang.org/x/codereview/patch" "io" "io/ioutil" "net/http" @@ -133,20 +134,24 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) { download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, boardsManagerTools, boardsManagerRFduinoTools, libraries) - patch(t) + patchFiles(t) } // FIXME: once patched cores are released, patching them will be unnecessary -func patch(t *testing.T) { +func patchFiles(t *testing.T) { files, err := ioutil.ReadDir(PATCHES_FOLDER) NoError(t, err) for _, file := range files { if filepath.Ext(file.Name()) == ".patch" { - cmd := exec.Command("patch", "-N", "-p0", "-r", "-", "-i", filepath.Join(PATCHES_FOLDER, file.Name())) - cmd.CombinedOutput() - //output, _ := cmd.CombinedOutput() - //fmt.Println(string(output)) + data, err := ioutil.ReadFile(Abs(t, filepath.Join(PATCHES_FOLDER, file.Name()))) + NoError(t, err) + patchSet, err := patch.Parse(data) + NoError(t, err) + operations, err := patchSet.Apply(ioutil.ReadFile) + for _, op := range operations { + ioutil.WriteFile(op.Dst, op.Data, os.FileMode(0644)) + } } } }