@@ -55,7 +55,6 @@ func TestDetermineBuildPathAndSketchName(t *testing.T) {
55
55
fqbn * cores.FQBN
56
56
resBuildPath string
57
57
resSketchName string
58
- hasError bool
59
58
}
60
59
61
60
blonk , err := sketches .NewSketchFromPath (paths .New ("testdata/Blonk" ))
@@ -66,52 +65,50 @@ func TestDetermineBuildPathAndSketchName(t *testing.T) {
66
65
67
66
tests := []test {
68
67
// 00: error: no data passed in
69
- {"" , "" , nil , nil , "<nil>" , "" , true },
68
+ {"" , "" , nil , nil , "<nil>" , "" },
70
69
// 01: use importFile to detect build.path and project_name
71
- {"testdata/build_path_2/Blink.ino.hex" , "" , nil , nil , "testdata/build_path_2" , "Blink.ino" , false },
70
+ {"testdata/build_path_2/Blink.ino.hex" , "" , nil , nil , "testdata/build_path_2" , "Blink.ino" },
72
71
// 02: use importPath as build.path and project_name
73
- {"" , "testdata/build_path_2" , nil , nil , "testdata/build_path_2" , "Blink.ino" , false },
72
+ {"" , "testdata/build_path_2" , nil , nil , "testdata/build_path_2" , "Blink.ino" },
74
73
// 03: error: used both importPath and importFile
75
- {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , nil , nil , "<nil>" , "" , true },
74
+ {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , nil , nil , "<nil>" , "" },
76
75
// 04: error: only sketch without FQBN
77
- {"" , "" , blonk , nil , "<nil>" , "" , true },
76
+ {"" , "" , blonk , nil , "<nil>" , "" },
78
77
// 05: use importFile to detect build.path and project_name, sketch is ignored.
79
- {"testdata/build_path_2/Blink.ino.hex" , "" , blonk , nil , "testdata/build_path_2" , "Blink.ino" , false },
78
+ {"testdata/build_path_2/Blink.ino.hex" , "" , blonk , nil , "testdata/build_path_2" , "Blink.ino" },
80
79
// 06: use importPath as build.path and Blink as project name, ignore the sketch Blonk
81
- {"" , "testdata/build_path_2" , blonk , nil , "testdata/build_path_2" , "Blink.ino" , false },
80
+ {"" , "testdata/build_path_2" , blonk , nil , "testdata/build_path_2" , "Blink.ino" },
82
81
// 07: error: used both importPath and importFile
83
- {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , blonk , nil , "<nil>" , "" , true },
82
+ {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , blonk , nil , "<nil>" , "" },
84
83
85
84
// 08: error: no data passed in
86
- {"" , "" , nil , fqbn , "<nil>" , "" , true },
85
+ {"" , "" , nil , fqbn , "<nil>" , "" },
87
86
// 09: use importFile to detect build.path and project_name, fqbn ignored
88
- {"testdata/build_path_2/Blink.ino.hex" , "" , nil , fqbn , "testdata/build_path_2" , "Blink.ino" , false },
87
+ {"testdata/build_path_2/Blink.ino.hex" , "" , nil , fqbn , "testdata/build_path_2" , "Blink.ino" },
89
88
// 10: use importPath as build.path and project_name, fqbn ignored
90
- {"" , "testdata/build_path_2" , nil , fqbn , "testdata/build_path_2" , "Blink.ino" , false },
89
+ {"" , "testdata/build_path_2" , nil , fqbn , "testdata/build_path_2" , "Blink.ino" },
91
90
// 11: error: used both importPath and importFile
92
- {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , nil , fqbn , "<nil>" , "" , true },
91
+ {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , nil , fqbn , "<nil>" , "" },
93
92
// 12: use sketch to determine project name and sketch+fqbn to determine build path
94
- {"" , "" , blonk , fqbn , "testdata/Blonk/build/arduino.samd.mkr1000" , "Blonk.ino" , false },
93
+ {"" , "" , blonk , fqbn , "testdata/Blonk/build/arduino.samd.mkr1000" , "Blonk.ino" },
95
94
// 13: use importFile to detect build.path and project_name, sketch+fqbn is ignored.
96
- {"testdata/build_path_2/Blink.ino.hex" , "" , blonk , fqbn , "testdata/build_path_2" , "Blink.ino" , false },
95
+ {"testdata/build_path_2/Blink.ino.hex" , "" , blonk , fqbn , "testdata/build_path_2" , "Blink.ino" },
97
96
// 14: use importPath as build.path and Blink as project name, ignore the sketch Blonk, ignore fqbn
98
- {"" , "testdata/build_path_2" , blonk , fqbn , "testdata/build_path_2" , "Blink.ino" , false },
97
+ {"" , "testdata/build_path_2" , blonk , fqbn , "testdata/build_path_2" , "Blink.ino" },
99
98
// 15: error: used both importPath and importFile
100
- {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , blonk , fqbn , "<nil>" , "" , true },
99
+ {"testdata/build_path_2/Blink.ino.hex" , "testdata/build_path_2" , blonk , fqbn , "<nil>" , "" },
101
100
}
102
101
for i , test := range tests {
103
102
t .Run (fmt .Sprintf ("SubTest%02d" , i ), func (t * testing.T ) {
104
103
buildPath , sketchName , err := determineBuildPathAndSketchName (test .importFile , test .importDir , test .sketch , test .fqbn )
105
- if test .hasError {
106
- require .Error (t , err )
107
- } else {
108
- require .NoError (t , err )
109
- }
110
104
if test .resBuildPath == "<nil>" {
105
+ require .Error (t , err )
111
106
require .Nil (t , buildPath )
112
107
} else {
108
+ require .NoError (t , err )
113
109
resBuildPath := paths .New (test .resBuildPath )
114
110
require .NoError (t , resBuildPath .ToAbs ())
111
+ require .NotNil (t , buildPath )
115
112
require .NoError (t , buildPath .ToAbs ())
116
113
require .Equal (t , resBuildPath .String (), buildPath .String ())
117
114
}
0 commit comments