@@ -34,50 +34,10 @@ import (
3434 "arduino.cc/builder/constants"
3535 "arduino.cc/builder/types"
3636 "github.com/stretchr/testify/require"
37- "os"
38- "path/filepath"
3937 "sort"
4038 "testing"
4139)
4240
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-
8141func TestIncludesFinderWithRegExp (t * testing.T ) {
8242 context := make (map [string ]interface {})
8343 ctx := & types.Context {}
@@ -86,9 +46,9 @@ func TestIncludesFinderWithRegExp(t *testing.T) {
8646 "#include <SPI.h>\n " +
8747 "^\n " +
8848 "compilation terminated."
89- context ["source" ] = output
49+ context [constants . CTX_SOURCE ] = output
9050
91- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
51+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
9252 err := parser .Run (context , ctx )
9353 NoError (t , err )
9454
@@ -103,9 +63,9 @@ func TestIncludesFinderWithRegExpEmptyOutput(t *testing.T) {
10363
10464 output := ""
10565
106- context ["source" ] = output
66+ context [constants . CTX_SOURCE ] = output
10767
108- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
68+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
10969 err := parser .Run (context , ctx )
11070 NoError (t , err )
11171
@@ -124,9 +84,9 @@ func TestIncludesFinderWithRegExpPreviousIncludes(t *testing.T) {
12484 "^\n " +
12585 "compilation terminated."
12686
127- context ["source" ] = output
87+ context [constants . CTX_SOURCE ] = output
12888
129- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
89+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
13090 err := parser .Run (context , ctx )
13191 NoError (t , err )
13292
@@ -145,9 +105,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes(t *testing.T) {
145105 " # include <Wire.h>\n " +
146106 " ^\n " +
147107 "compilation terminated.\n "
148- context ["source" ] = output
108+ context [constants . CTX_SOURCE ] = output
149109
150- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
110+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
151111 err := parser .Run (context , ctx )
152112 NoError (t , err )
153113
@@ -165,9 +125,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes2(t *testing.T) {
165125 " #\t \t \t include <Wire.h>\n " +
166126 " ^\n " +
167127 "compilation terminated.\n "
168- context ["source" ] = output
128+ context [constants . CTX_SOURCE ] = output
169129
170- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
130+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
171131 err := parser .Run (context , ctx )
172132 NoError (t , err )
173133
@@ -184,9 +144,9 @@ func TestIncludesFinderWithRegExpPaddedIncludes3(t *testing.T) {
184144 output := "/some/path/sketch.ino:1:33: fatal error: SPI.h: No such file or directory\n " +
185145 "compilation terminated.\n "
186146
187- context ["source" ] = output
147+ context [constants . CTX_SOURCE ] = output
188148
189- parser := builder.IncludesFinderWithRegExp {ContextField : "source" }
149+ parser := builder.IncludesFinderWithRegExp {ContextField : constants . CTX_SOURCE }
190150 err := parser .Run (context , ctx )
191151 NoError (t , err )
192152
0 commit comments