Skip to content

Commit f5230a2

Browse files
temporary disable legacy test, before porting them to the new infra
1 parent 7d7a177 commit f5230a2

File tree

2 files changed

+128
-138
lines changed

2 files changed

+128
-138
lines changed
-17.1 MB
Binary file not shown.

Diff for: legacy/builder/test/setup_build_properties_test.go

+128-138
Original file line numberDiff line numberDiff line change
@@ -15,142 +15,132 @@
1515

1616
package test
1717

18-
import (
19-
"path/filepath"
20-
"testing"
21-
22-
"github.com/arduino/arduino-cli/legacy/builder/types"
23-
paths "github.com/arduino/go-paths-helper"
24-
"github.com/arduino/go-properties-orderedmap"
25-
"github.com/stretchr/testify/require"
26-
)
27-
2818
// TODO maybe create a test that actually check all the keys
29-
func TestSetupBuildProperties(t *testing.T) {
30-
ctx := &types.Context{
31-
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
32-
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
33-
}
34-
ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno")
35-
defer cleanUpBuilderTestContext(t, ctx)
36-
37-
buildProperties := ctx.Builder.GetBuildProperties()
38-
39-
require.Equal(t, "ARDUINO", buildProperties.Get("software"))
40-
41-
require.Equal(t, "uno", buildProperties.Get("_id"))
42-
require.Equal(t, "Arduino/Genuino Uno", buildProperties.Get("name"))
43-
require.Equal(t, "0x2341", buildProperties.Get("vid.0"))
44-
require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern"))
45-
require.Equal(t, "{path}/etc/avrdude.conf", buildProperties.Get("tools.avrdude.config.path"))
46-
47-
requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), "downloaded_hardware/arduino/avr")
48-
requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), "downloaded_hardware/arduino")
49-
require.Equal(t, "10607", buildProperties.Get("runtime.ide.version"))
50-
require.NotEmpty(t, buildProperties.Get("runtime.os"))
51-
52-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
53-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
54-
55-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude-6.0.1-arduino5.path"), "tools_builtin/avr", "downloaded_tools/avrdude/6.0.1-arduino5")
56-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude.path"), "tools_builtin/avr", "downloaded_tools/avrdude/6.0.1-arduino5")
57-
58-
bossacPath := buildProperties.Get("runtime.tools.bossac.path")
59-
bossac161Path := buildProperties.Get("runtime.tools.bossac-1.6.1-arduino.path")
60-
bossac15Path := buildProperties.Get("runtime.tools.bossac-1.5-arduino.path")
61-
requireEquivalentPaths(t, bossac161Path, "downloaded_tools/bossac/1.6.1-arduino")
62-
requireEquivalentPaths(t, bossac15Path, "downloaded_tools/bossac/1.5-arduino")
63-
requireEquivalentPaths(t, bossacPath, bossac161Path, bossac15Path)
64-
65-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr")
66-
67-
requireEquivalentPaths(t, buildProperties.Get("build.source.path"), "sketch1")
68-
69-
require.True(t, buildProperties.ContainsKey("extra.time.utc"))
70-
require.True(t, buildProperties.ContainsKey("extra.time.local"))
71-
require.True(t, buildProperties.ContainsKey("extra.time.zone"))
72-
require.True(t, buildProperties.ContainsKey("extra.time.dst"))
73-
}
74-
75-
// TODO make this integration tests
76-
func TestSetupBuildPropertiesWithSomeCustomOverrides(t *testing.T) {
77-
ctx := &types.Context{
78-
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
79-
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
80-
}
81-
ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno")
82-
defer cleanUpBuilderTestContext(t, ctx)
83-
customBuildProp := []string{"name=fake name", "tools.avrdude.config.path=non existent path with space and a ="}
84-
customProps, err := properties.LoadFromSlice(customBuildProp)
85-
require.NoError(t, err)
86-
87-
buildProperties := ctx.Builder.GetBuildProperties().Merge(customProps)
88-
require.Equal(t, "ARDUINO", buildProperties.Get("software"))
89-
require.Equal(t, "uno", buildProperties.Get("_id"))
90-
require.Equal(t, "fake name", buildProperties.Get("name"))
91-
require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern"))
92-
require.Equal(t, "non existent path with space and a =", buildProperties.Get("tools.avrdude.config.path"))
93-
}
94-
95-
// TODO go to compile_4 that uses the custom_yum to compile and we also verify this properties
96-
func TestSetupBuildPropertiesUserHardware(t *testing.T) {
97-
ctx := &types.Context{
98-
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
99-
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
100-
}
101-
ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:custom_yun")
102-
defer cleanUpBuilderTestContext(t, ctx)
103-
104-
buildProperties := ctx.Builder.GetBuildProperties()
105-
106-
require.Equal(t, "ARDUINO", buildProperties.Get("software"))
107-
108-
require.Equal(t, "custom_yun", buildProperties.Get("_id"))
109-
require.Equal(t, "caterina/Caterina-custom_yun.hex", buildProperties.Get("bootloader.file"))
110-
requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), filepath.Join("user_hardware", "my_avr_platform", "avr"))
111-
requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), filepath.Join("user_hardware", "my_avr_platform"))
112-
}
113-
114-
func TestSetupBuildPropertiesWithMissingPropsFromParentPlatformTxtFiles(t *testing.T) {
115-
ctx := &types.Context{
116-
HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
117-
BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
118-
}
119-
ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:custom_yun")
120-
defer cleanUpBuilderTestContext(t, ctx)
121-
122-
buildProperties := ctx.Builder.GetBuildProperties()
123-
124-
require.Equal(t, "ARDUINO", buildProperties.Get("software"))
125-
126-
require.Equal(t, "custom_yun", buildProperties.Get("_id"))
127-
require.Equal(t, "Arduino Yún", buildProperties.Get("name"))
128-
require.Equal(t, "0x2341", buildProperties.Get("vid.0"))
129-
require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern"))
130-
require.Equal(t, "{path}/etc/avrdude.conf", buildProperties.Get("tools.avrdude.config.path"))
131-
132-
requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), "user_hardware/my_avr_platform/avr")
133-
requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), "user_hardware/my_avr_platform")
134-
require.Equal(t, "10607", buildProperties.Get("runtime.ide.version"))
135-
require.NotEmpty(t, buildProperties.Get("runtime.os"))
136-
137-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
138-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
139-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac-1.6.1-arduino.path"), "downloaded_tools/bossac/1.6.1-arduino")
140-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac-1.5-arduino.path"), "downloaded_tools/bossac/1.5-arduino")
141-
142-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac.path"), "downloaded_tools/bossac/1.6.1-arduino", "downloaded_tools/bossac/1.5-arduino")
143-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude.path"), "downloaded_tools/avrdude/6.0.1-arduino5", "tools_builtin/avr")
144-
145-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude-6.0.1-arduino5.path"), "downloaded_tools/avrdude/6.0.1-arduino5", "tools_builtin/avr")
146-
147-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr")
148-
requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc-4.8.1-arduino5.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr")
149-
150-
requireEquivalentPaths(t, buildProperties.Get("build.source.path"), "sketch1")
151-
152-
require.True(t, buildProperties.ContainsKey("extra.time.utc"))
153-
require.True(t, buildProperties.ContainsKey("extra.time.local"))
154-
require.True(t, buildProperties.ContainsKey("extra.time.zone"))
155-
require.True(t, buildProperties.ContainsKey("extra.time.dst"))
156-
}
19+
//func TestSetupBuildProperties(t *testing.T) {
20+
// ctx := &types.Context{
21+
// HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
22+
// BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
23+
// }
24+
// ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno")
25+
// defer cleanUpBuilderTestContext(t, ctx)
26+
//
27+
// buildProperties := ctx.Builder.GetBuildProperties()
28+
//
29+
// require.Equal(t, "ARDUINO", buildProperties.Get("software"))
30+
//
31+
// require.Equal(t, "uno", buildProperties.Get("_id"))
32+
// require.Equal(t, "Arduino/Genuino Uno", buildProperties.Get("name"))
33+
// require.Equal(t, "0x2341", buildProperties.Get("vid.0"))
34+
// require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern"))
35+
// require.Equal(t, "{path}/etc/avrdude.conf", buildProperties.Get("tools.avrdude.config.path"))
36+
//
37+
// requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), "downloaded_hardware/arduino/avr")
38+
// requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), "downloaded_hardware/arduino")
39+
// require.Equal(t, "10607", buildProperties.Get("runtime.ide.version"))
40+
// require.NotEmpty(t, buildProperties.Get("runtime.os"))
41+
//
42+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
43+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
44+
//
45+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude-6.0.1-arduino5.path"), "tools_builtin/avr", "downloaded_tools/avrdude/6.0.1-arduino5")
46+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude.path"), "tools_builtin/avr", "downloaded_tools/avrdude/6.0.1-arduino5")
47+
//
48+
// bossacPath := buildProperties.Get("runtime.tools.bossac.path")
49+
// bossac161Path := buildProperties.Get("runtime.tools.bossac-1.6.1-arduino.path")
50+
// bossac15Path := buildProperties.Get("runtime.tools.bossac-1.5-arduino.path")
51+
// requireEquivalentPaths(t, bossac161Path, "downloaded_tools/bossac/1.6.1-arduino")
52+
// requireEquivalentPaths(t, bossac15Path, "downloaded_tools/bossac/1.5-arduino")
53+
// requireEquivalentPaths(t, bossacPath, bossac161Path, bossac15Path)
54+
//
55+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr")
56+
//
57+
// requireEquivalentPaths(t, buildProperties.Get("build.source.path"), "sketch1")
58+
//
59+
// require.True(t, buildProperties.ContainsKey("extra.time.utc"))
60+
// require.True(t, buildProperties.ContainsKey("extra.time.local"))
61+
// require.True(t, buildProperties.ContainsKey("extra.time.zone"))
62+
// require.True(t, buildProperties.ContainsKey("extra.time.dst"))
63+
//}
64+
//
65+
//// TODO make this integration tests
66+
//func TestSetupBuildPropertiesWithSomeCustomOverrides(t *testing.T) {
67+
// ctx := &types.Context{
68+
// HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware"),
69+
// BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
70+
// }
71+
// ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "arduino:avr:uno")
72+
// defer cleanUpBuilderTestContext(t, ctx)
73+
// customBuildProp := []string{"name=fake name", "tools.avrdude.config.path=non existent path with space and a ="}
74+
// customProps, err := properties.LoadFromSlice(customBuildProp)
75+
// require.NoError(t, err)
76+
//
77+
// buildProperties := ctx.Builder.GetBuildProperties().Merge(customProps)
78+
// require.Equal(t, "ARDUINO", buildProperties.Get("software"))
79+
// require.Equal(t, "uno", buildProperties.Get("_id"))
80+
// require.Equal(t, "fake name", buildProperties.Get("name"))
81+
// require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern"))
82+
// require.Equal(t, "non existent path with space and a =", buildProperties.Get("tools.avrdude.config.path"))
83+
//}
84+
//
85+
//// TODO go to compile_4 that uses the custom_yum to compile and we also verify this properties
86+
//func TestSetupBuildPropertiesUserHardware(t *testing.T) {
87+
// ctx := &types.Context{
88+
// HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
89+
// BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
90+
// }
91+
// ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:custom_yun")
92+
// defer cleanUpBuilderTestContext(t, ctx)
93+
//
94+
// buildProperties := ctx.Builder.GetBuildProperties()
95+
//
96+
// require.Equal(t, "ARDUINO", buildProperties.Get("software"))
97+
//
98+
// require.Equal(t, "custom_yun", buildProperties.Get("_id"))
99+
// require.Equal(t, "caterina/Caterina-custom_yun.hex", buildProperties.Get("bootloader.file"))
100+
// requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), filepath.Join("user_hardware", "my_avr_platform", "avr"))
101+
// requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), filepath.Join("user_hardware", "my_avr_platform"))
102+
//}
103+
//
104+
//func TestSetupBuildPropertiesWithMissingPropsFromParentPlatformTxtFiles(t *testing.T) {
105+
// ctx := &types.Context{
106+
// HardwareDirs: paths.NewPathList(filepath.Join("..", "hardware"), "downloaded_hardware", "user_hardware"),
107+
// BuiltInToolsDirs: paths.NewPathList("downloaded_tools", "tools_builtin"),
108+
// }
109+
// ctx = prepareBuilderTestContext(t, ctx, paths.New("sketch1", "sketch1.ino"), "my_avr_platform:avr:custom_yun")
110+
// defer cleanUpBuilderTestContext(t, ctx)
111+
//
112+
// buildProperties := ctx.Builder.GetBuildProperties()
113+
//
114+
// require.Equal(t, "ARDUINO", buildProperties.Get("software"))
115+
//
116+
// require.Equal(t, "custom_yun", buildProperties.Get("_id"))
117+
// require.Equal(t, "Arduino Yún", buildProperties.Get("name"))
118+
// require.Equal(t, "0x2341", buildProperties.Get("vid.0"))
119+
// require.Equal(t, "\"{compiler.path}{compiler.c.cmd}\" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} \"{source_file}\" -o \"{object_file}\"", buildProperties.Get("recipe.c.o.pattern"))
120+
// require.Equal(t, "{path}/etc/avrdude.conf", buildProperties.Get("tools.avrdude.config.path"))
121+
//
122+
// requireEquivalentPaths(t, buildProperties.Get("runtime.platform.path"), "user_hardware/my_avr_platform/avr")
123+
// requireEquivalentPaths(t, buildProperties.Get("runtime.hardware.path"), "user_hardware/my_avr_platform")
124+
// require.Equal(t, "10607", buildProperties.Get("runtime.ide.version"))
125+
// require.NotEmpty(t, buildProperties.Get("runtime.os"))
126+
//
127+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
128+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path"), "downloaded_tools/arm-none-eabi-gcc/4.8.3-2014q1")
129+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac-1.6.1-arduino.path"), "downloaded_tools/bossac/1.6.1-arduino")
130+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac-1.5-arduino.path"), "downloaded_tools/bossac/1.5-arduino")
131+
//
132+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.bossac.path"), "downloaded_tools/bossac/1.6.1-arduino", "downloaded_tools/bossac/1.5-arduino")
133+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude.path"), "downloaded_tools/avrdude/6.0.1-arduino5", "tools_builtin/avr")
134+
//
135+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avrdude-6.0.1-arduino5.path"), "downloaded_tools/avrdude/6.0.1-arduino5", "tools_builtin/avr")
136+
//
137+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr")
138+
// requireEquivalentPaths(t, buildProperties.Get("runtime.tools.avr-gcc-4.8.1-arduino5.path"), "downloaded_tools/avr-gcc/4.8.1-arduino5", "tools_builtin/avr")
139+
//
140+
// requireEquivalentPaths(t, buildProperties.Get("build.source.path"), "sketch1")
141+
//
142+
// require.True(t, buildProperties.ContainsKey("extra.time.utc"))
143+
// require.True(t, buildProperties.ContainsKey("extra.time.local"))
144+
// require.True(t, buildProperties.ContainsKey("extra.time.zone"))
145+
// require.True(t, buildProperties.ContainsKey("extra.time.dst"))
146+
//}

0 commit comments

Comments
 (0)