@@ -34,50 +34,10 @@ import (
34
34
"arduino.cc/builder/constants"
35
35
"arduino.cc/builder/types"
36
36
"github.com/stretchr/testify/require"
37
- "os"
38
- "path/filepath"
39
37
"sort"
40
38
"testing"
41
39
)
42
40
43
- func TestIncludesFinderWithRegExpCoanOutput (t * testing.T ) {
44
- DownloadCoresAndToolsAndLibraries (t )
45
-
46
- context := make (map [string ]interface {})
47
- ctx := & types.Context {
48
- HardwareFolders : []string {filepath .Join (".." , "hardware" ), "hardware" , "downloaded_hardware" },
49
- ToolsFolders : []string {"downloaded_tools" },
50
- SketchLocation : filepath .Join ("sketch2" , "SketchWithIfDef.ino" ),
51
- FQBN : "arduino:avr:leonardo" ,
52
- ArduinoAPIVersion : "10600" ,
53
- Verbose : true ,
54
- }
55
-
56
- buildPath := SetupBuildPath (t , ctx )
57
- defer os .RemoveAll (buildPath )
58
-
59
- commands := []types.Command {
60
- & builder.ContainerSetupHardwareToolsLibsSketchAndProps {},
61
-
62
- & builder.ContainerMergeCopySketchFiles {},
63
-
64
- & builder.CoanRunner {},
65
-
66
- & builder.IncludesFinderWithRegExp {ContextField : constants .CTX_SOURCE },
67
- }
68
-
69
- for _ , command := range commands {
70
- err := command .Run (context , ctx )
71
- NoError (t , err )
72
- }
73
-
74
- includes := ctx .Includes
75
- require .Equal (t , 3 , len (includes ))
76
- require .Equal (t , "Arduino.h" , includes [0 ])
77
- require .Equal (t , "empty_1.h" , includes [1 ])
78
- require .Equal (t , "empty_2.h" , includes [2 ])
79
- }
80
-
81
41
func TestIncludesFinderWithRegExp (t * testing.T ) {
82
42
context := make (map [string ]interface {})
83
43
ctx := & types.Context {}
@@ -86,9 +46,9 @@ func TestIncludesFinderWithRegExp(t *testing.T) {
86
46
"#include <SPI.h>\n " +
87
47
"^\n " +
88
48
"compilation terminated."
89
- context ["source" ] = output
49
+ context [constants . CTX_SOURCE ] = output
90
50
91
- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
51
+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
92
52
err := parser .Run (context , ctx )
93
53
NoError (t , err )
94
54
@@ -103,9 +63,9 @@ func TestIncludesFinderWithRegExpEmptyOutput(t *testing.T) {
103
63
104
64
output := ""
105
65
106
- context ["source" ] = output
66
+ context [constants . CTX_SOURCE ] = output
107
67
108
- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
68
+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
109
69
err := parser .Run (context , ctx )
110
70
NoError (t , err )
111
71
@@ -124,9 +84,9 @@ func TestIncludesFinderWithRegExpPreviousIncludes(t *testing.T) {
124
84
"^\n " +
125
85
"compilation terminated."
126
86
127
- context ["source" ] = output
87
+ context [constants . CTX_SOURCE ] = output
128
88
129
- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
89
+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
130
90
err := parser .Run (context , ctx )
131
91
NoError (t , err )
132
92
@@ -145,9 +105,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes(t *testing.T) {
145
105
" # include <Wire.h>\n " +
146
106
" ^\n " +
147
107
"compilation terminated.\n "
148
- context ["source" ] = output
108
+ context [constants . CTX_SOURCE ] = output
149
109
150
- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
110
+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
151
111
err := parser .Run (context , ctx )
152
112
NoError (t , err )
153
113
@@ -165,9 +125,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes2(t *testing.T) {
165
125
" #\t \t \t include <Wire.h>\n " +
166
126
" ^\n " +
167
127
"compilation terminated.\n "
168
- context ["source" ] = output
128
+ context [constants . CTX_SOURCE ] = output
169
129
170
- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
130
+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
171
131
err := parser .Run (context , ctx )
172
132
NoError (t , err )
173
133
@@ -184,9 +144,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes3(t *testing.T) {
184
144
output := "/some/path/sketch.ino:1:33: fatal error: SPI.h: No such file or directory\n " +
185
145
"compilation terminated.\n "
186
146
187
- context ["source" ] = output
147
+ context [constants . CTX_SOURCE ] = output
188
148
189
- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
149
+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
190
150
err := parser .Run (context , ctx )
191
151
NoError (t , err )
192
152
0 commit comments