From 7fb7e76098e9062eb54a7cc140d19cf74f6a7469 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 6 May 2016 12:27:40 +0200 Subject: [PATCH 1/3] Remove empty downloaded_* directories These are created automatically when their contents is actually downloaded during testing, so there is no need to keep empty directories in git. By removing them it is possible to share the same directories between multiple git working trees, by simply making symlinks (which was not possible before without ending up with a modified working tree). Signed-off-by: Matthijs Kooijman --- src/arduino.cc/builder/test/.gitignore | 1 + .../builder/test/downloaded_board_manager_stuff/.gitignore | 3 --- src/arduino.cc/builder/test/downloaded_hardware/.gitignore | 1 - src/arduino.cc/builder/test/downloaded_libraries/.gitignore | 1 - src/arduino.cc/builder/test/downloaded_stuff_patches/.gitkeep | 0 src/arduino.cc/builder/test/downloaded_tools/.gitignore | 3 --- src/arduino.cc/builder/test/helper_tools_downloader.go | 2 ++ 7 files changed, 3 insertions(+), 8 deletions(-) create mode 100644 src/arduino.cc/builder/test/.gitignore delete mode 100644 src/arduino.cc/builder/test/downloaded_board_manager_stuff/.gitignore delete mode 100644 src/arduino.cc/builder/test/downloaded_hardware/.gitignore delete mode 100644 src/arduino.cc/builder/test/downloaded_libraries/.gitignore delete mode 100644 src/arduino.cc/builder/test/downloaded_stuff_patches/.gitkeep delete mode 100644 src/arduino.cc/builder/test/downloaded_tools/.gitignore diff --git a/src/arduino.cc/builder/test/.gitignore b/src/arduino.cc/builder/test/.gitignore new file mode 100644 index 00000000..c49bbb5b --- /dev/null +++ b/src/arduino.cc/builder/test/.gitignore @@ -0,0 +1 @@ +downloaded_* diff --git a/src/arduino.cc/builder/test/downloaded_board_manager_stuff/.gitignore b/src/arduino.cc/builder/test/downloaded_board_manager_stuff/.gitignore deleted file mode 100644 index bc0a8874..00000000 --- a/src/arduino.cc/builder/test/downloaded_board_manager_stuff/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -arduino -RedBearLab -RFduino \ No newline at end of file diff --git a/src/arduino.cc/builder/test/downloaded_hardware/.gitignore b/src/arduino.cc/builder/test/downloaded_hardware/.gitignore deleted file mode 100644 index e92b7dd6..00000000 --- a/src/arduino.cc/builder/test/downloaded_hardware/.gitignore +++ /dev/null @@ -1 +0,0 @@ -arduino \ No newline at end of file diff --git a/src/arduino.cc/builder/test/downloaded_libraries/.gitignore b/src/arduino.cc/builder/test/downloaded_libraries/.gitignore deleted file mode 100644 index 72e8ffc0..00000000 --- a/src/arduino.cc/builder/test/downloaded_libraries/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/src/arduino.cc/builder/test/downloaded_stuff_patches/.gitkeep b/src/arduino.cc/builder/test/downloaded_stuff_patches/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/arduino.cc/builder/test/downloaded_tools/.gitignore b/src/arduino.cc/builder/test/downloaded_tools/.gitignore deleted file mode 100644 index 5a0e4ff4..00000000 --- a/src/arduino.cc/builder/test/downloaded_tools/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -a* -b* -c* diff --git a/src/arduino.cc/builder/test/helper_tools_downloader.go b/src/arduino.cc/builder/test/helper_tools_downloader.go index 3730635d..3233d3a1 100644 --- a/src/arduino.cc/builder/test/helper_tools_downloader.go +++ b/src/arduino.cc/builder/test/helper_tools_downloader.go @@ -139,6 +139,8 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) { } func patchFiles(t *testing.T) { + err := utils.EnsureFolderExists(PATCHES_FOLDER) + NoError(t, err) files, err := ioutil.ReadDir(PATCHES_FOLDER) NoError(t, err) From ed7176f6914c918f07902d6bb73bec8782b2fc19 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 6 May 2016 14:49:21 +0200 Subject: [PATCH 2/3] Improve documentation on running tests This more verbosely explains what the -v and -timeout options are for (and removes them from the default command shown). Also, this adds info on how to run a single test. Signed-off-by: Matthijs Kooijman --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 95192d4b..856ca2fa 100644 --- a/README.md +++ b/README.md @@ -75,14 +75,37 @@ go build arduino.cc/arduino-builder In order to run the tests, type: ``` -go test -timeout 60m -v ./src/arduino.cc/builder/test/... +go test arduino.cc/builder/test +``` + +This runs all tests, showing any failures and a summary at the end. +Add the -v option to show each test as it is being ran. Currently, +arduino-builder itself also generates copious output, even for +non-failing testcases and without -v, and testing does not stop at the +first failure, so you probably want to redirect test output so you can +scroll back to find any failures. + +To run a single test, use the -run option, which accepts a regular +expression (see also go help testflag). + +``` +go test arduino.cc/builder/test -run 'TestBuilderEmptySketch' +go test arduino.cc/builder/test -run 'TestPrototypesAdder.*' ``` In jenkins, use ``` -go test -timeout 60m -v ./src/arduino.cc/builder/test/... | bin/go-junit-report > report.xml +go test -v arduino.cc/builder/test | bin/go-junit-report > report.xml ``` +The first time you run the tests, some needed files (toolchains and +source files) will be downloaded, which needs about 1GB of space (at the +time of writing). If you have a slow connection, this download might +exceed the default 10 minute timeout for a single test. If you run into +this, add `-timeout 60m` or similar to the commandline to extend the +timeout. If you are running on slower system (like a rasbperry pi), +increasing the timeout might be needed as well. + ### License and Copyright `arduino-builder` is licensed under General Public License version 2, as published by the Free Software Foundation. See [LICENSE.txt](LICENSE.txt). From 3b52ee45aaef6e22f44f596db06ab5e9d9325269 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 9 May 2016 12:23:29 +0200 Subject: [PATCH 3/3] Fix tool loading testcases In commit 7520e66 (Removed no more used "coan" tools), one tool was removed, but these testcases were not updated accordingly. This commit updates the testcases with the correct number of tools to expect. While here, the testcases are expanded to also explicitely check the name and version number for all tools. This makes the test more complete, but also documents what tools and versions are expected exactly, which makes it easier to diagnose problems like this one later. Also, instead of using hardcoded array indices, this converts the latter two testcases to use an idx variable, just like the first testcase. This makes it easier to insert a new tool later. Signed-off-by: Matthijs Kooijman --- .../builder/test/tools_loader_test.go | 67 ++++++++++++++----- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/arduino.cc/builder/test/tools_loader_test.go b/src/arduino.cc/builder/test/tools_loader_test.go index 2c85a942..87dfb12e 100644 --- a/src/arduino.cc/builder/test/tools_loader_test.go +++ b/src/arduino.cc/builder/test/tools_loader_test.go @@ -64,7 +64,7 @@ func TestLoadTools(t *testing.T) { NoError(t, err) tools := ctx.Tools - require.Equal(t, 7, len(tools)) + require.Equal(t, 6, len(tools)) sort.Sort(ByToolIDAndVersion(tools)) @@ -88,6 +88,10 @@ func TestLoadTools(t *testing.T) { require.Equal(t, "bossac", tools[idx].Name) require.Equal(t, "1.6.1-arduino", tools[idx].Version) require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.6.1-arduino"), tools[idx].Folder) + idx++ + require.Equal(t, "ctags", tools[idx].Name) + require.Equal(t, "5.8-arduino10", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/ctags/5.8-arduino10"), tools[idx].Folder) } func TestLoadToolsWithBoardManagerFolderStructure(t *testing.T) { @@ -106,14 +110,18 @@ func TestLoadToolsWithBoardManagerFolderStructure(t *testing.T) { sort.Sort(ByToolIDAndVersion(tools)) - require.Equal(t, "CMSIS", tools[0].Name) - require.Equal(t, "arm-none-eabi-gcc", tools[1].Name) - require.Equal(t, "4.8.3-2014q1", tools[1].Version) - require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1"), tools[1].Folder) - - require.Equal(t, "openocd", tools[2].Name) - require.Equal(t, "0.9.0-arduino", tools[2].Version) - require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/arduino/tools/openocd/0.9.0-arduino"), tools[2].Folder) + idx := 0 + require.Equal(t, "CMSIS", tools[idx].Name) + require.Equal(t, "4.0.0-atmel", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/arduino/tools/CMSIS/4.0.0-atmel"), tools[idx].Folder) + idx++ + require.Equal(t, "arm-none-eabi-gcc", tools[idx].Name) + require.Equal(t, "4.8.3-2014q1", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1"), tools[idx].Folder) + idx++ + require.Equal(t, "openocd", tools[idx].Name) + require.Equal(t, "0.9.0-arduino", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/arduino/tools/openocd/0.9.0-arduino"), tools[idx].Folder) } func TestLoadLotsOfTools(t *testing.T) { @@ -128,13 +136,40 @@ func TestLoadLotsOfTools(t *testing.T) { NoError(t, err) tools := ctx.Tools - require.Equal(t, 9, len(tools)) + require.Equal(t, 8, len(tools)) - require.Equal(t, "arm-none-eabi-gcc", tools[0].Name) - require.Equal(t, "4.8.3-2014q1", tools[0].Version) + sort.Sort(ByToolIDAndVersion(tools)) - require.Equal(t, "CMSIS", tools[7].Name) - require.Equal(t, "openocd", tools[8].Name) - require.Equal(t, "0.9.0-arduino", tools[8].Version) - require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/arduino/tools/openocd/0.9.0-arduino"), tools[8].Folder) + idx := 0 + require.Equal(t, "CMSIS", tools[idx].Name) + require.Equal(t, "4.0.0-atmel", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/arduino/tools/CMSIS/4.0.0-atmel"), tools[idx].Folder) + idx++ + require.Equal(t, "arm-none-eabi-gcc", tools[idx].Name) + require.Equal(t, "4.8.3-2014q1", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1"), tools[idx].Folder) + idx++ + require.Equal(t, "avr-gcc", tools[idx].Name) + require.Equal(t, "4.8.1-arduino5", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/avr-gcc/4.8.1-arduino5"), tools[idx].Folder) + idx++ + require.Equal(t, "avrdude", tools[idx].Name) + require.Equal(t, "6.0.1-arduino5", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/avrdude/6.0.1-arduino5"), tools[idx].Folder) + idx++ + require.Equal(t, "bossac", tools[idx].Name) + require.Equal(t, "1.5-arduino", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.5-arduino"), tools[idx].Folder) + idx++ + require.Equal(t, "bossac", tools[idx].Name) + require.Equal(t, "1.6.1-arduino", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/bossac/1.6.1-arduino"), tools[idx].Folder) + idx++ + require.Equal(t, "ctags", tools[idx].Name) + require.Equal(t, "5.8-arduino10", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_tools/ctags/5.8-arduino10"), tools[idx].Folder) + idx++ + require.Equal(t, "openocd", tools[idx].Name) + require.Equal(t, "0.9.0-arduino", tools[idx].Version) + require.Equal(t, Abs(t, "./downloaded_board_manager_stuff/arduino/tools/openocd/0.9.0-arduino"), tools[idx].Folder) }