Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
3656f477
Commit
3656f477
authored
Jul 08, 2019
by
Massimiliano Pippi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix regex and add test
parent
ae3881b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
arduino/builder/sketch.go
arduino/builder/sketch.go
+1
-1
arduino/builder/sketch_test.go
arduino/builder/sketch_test.go
+11
-0
arduino/builder/testdata/TestMergeSketchSourcesArduinoIncluded/TestMergeSketchSourcesArduinoIncluded.ino
...ArduinoIncluded/TestMergeSketchSourcesArduinoIncluded.ino
+9
-0
No files found.
arduino/builder/sketch.go
View file @
3656f477
...
...
@@ -28,7 +28,7 @@ import (
"github.com/pkg/errors"
)
var
includesArduinoH
=
regexp
.
MustCompile
(
`^\s*#\s*include\s*[<\"]Arduino\.h[>\"]`
)
var
includesArduinoH
=
regexp
.
MustCompile
(
`
(?m)
^\s*#\s*include\s*[<\"]Arduino\.h[>\"]`
)
// QuoteCppString returns the given string as a quoted string for use with the C
// preprocessor. This adds double quotes around it and escapes any
...
...
arduino/builder/sketch_test.go
View file @
3656f477
...
...
@@ -19,6 +19,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/arduino/arduino-cli/arduino/builder"
...
...
@@ -107,3 +108,13 @@ func TestMergeSketchSources(t *testing.T) {
assert
.
Equal
(
t
,
2
,
offset
)
assert
.
Equal
(
t
,
string
(
mergedBytes
),
source
)
}
func
TestMergeSketchSourcesArduinoIncluded
(
t
*
testing
.
T
)
{
s
,
err
:=
builder
.
LoadSketch
(
filepath
.
Join
(
"testdata"
,
t
.
Name
()),
""
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
s
)
// ensure not to include Arduino.h when it's already there
_
,
source
:=
builder
.
MergeSketchSources
(
s
)
assert
.
Equal
(
t
,
1
,
strings
.
Count
(
source
,
"<Arduino.h>"
))
}
arduino/builder/testdata/TestMergeSketchSourcesArduinoIncluded/TestMergeSketchSourcesArduinoIncluded.ino
0 → 100644
View file @
3656f477
// a comment
# include <Arduino.h>
void
setup
()
{
}
void
loop
()
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment