@@ -77,13 +77,15 @@ func TestLoadSketch(t *testing.T) {
77
77
context := make (map [string ]interface {})
78
78
context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch1" , "sketch.ino" )
79
79
80
- loggerCommand := builder.SetupHumanLoggerIfMissing {}
81
- err := loggerCommand .Run (context )
82
- NoError (t , err )
80
+ commands := []types.Command {
81
+ & builder.SetupHumanLoggerIfMissing {},
82
+ & builder.SketchLoader {},
83
+ }
83
84
84
- loader := builder.SketchLoader {}
85
- err = loader .Run (context )
86
- NoError (t , err )
85
+ for _ , command := range commands {
86
+ err := command .Run (context )
87
+ NoError (t , err )
88
+ }
87
89
88
90
sketch := context [constants .CTX_SKETCH ].(* types.Sketch )
89
91
require .NotNil (t , sketch )
@@ -119,13 +121,15 @@ func TestLoadSketchFromFolder(t *testing.T) {
119
121
context := make (map [string ]interface {})
120
122
context [constants .CTX_SKETCH_LOCATION ] = "sketch_with_subfolders"
121
123
122
- loggerCommand := builder.SetupHumanLoggerIfMissing {}
123
- err := loggerCommand .Run (context )
124
- NoError (t , err )
124
+ commands := []types.Command {
125
+ & builder.SetupHumanLoggerIfMissing {},
126
+ & builder.SketchLoader {},
127
+ }
125
128
126
- loader := builder.SketchLoader {}
127
- err = loader .Run (context )
128
- NoError (t , err )
129
+ for _ , command := range commands {
130
+ err := command .Run (context )
131
+ NoError (t , err )
132
+ }
129
133
130
134
sketch := context [constants .CTX_SKETCH ].(* types.Sketch )
131
135
require .NotNil (t , sketch )
@@ -135,3 +139,26 @@ func TestLoadSketchFromFolder(t *testing.T) {
135
139
require .Equal (t , 1 , len (sketch .AdditionalFiles ))
136
140
require .True (t , strings .Index (sketch .AdditionalFiles [0 ].Name , "other.cpp" ) != - 1 )
137
141
}
142
+
143
+ func TestLoadSketchWithBackup (t * testing.T ) {
144
+ context := make (map [string ]interface {})
145
+ context [constants .CTX_SKETCH_LOCATION ] = filepath .Join ("sketch_with_backup_files" , "sketch.ino" )
146
+
147
+ commands := []types.Command {
148
+ & builder.SetupHumanLoggerIfMissing {},
149
+ & builder.SketchLoader {},
150
+ }
151
+
152
+ for _ , command := range commands {
153
+ err := command .Run (context )
154
+ NoError (t , err )
155
+ }
156
+
157
+ sketch := context [constants .CTX_SKETCH ].(* types.Sketch )
158
+ require .NotNil (t , sketch )
159
+
160
+ require .True (t , strings .Index (sketch .MainFile .Name , "sketch.ino" ) != - 1 )
161
+
162
+ require .Equal (t , 0 , len (sketch .AdditionalFiles ))
163
+ require .Equal (t , 0 , len (sketch .OtherSketchFiles ))
164
+ }
0 commit comments