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
443717fa
Commit
443717fa
authored
Dec 24, 2018
by
Cristian Maglie
Committed by
Cristian Maglie
Jan 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for upload command (parsing only)
parent
29c1182e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
0 deletions
+121
-0
commands/commands_test.go
commands/commands_test.go
+82
-0
commands/testdata/sketchbook_with_custom_hardware/TestSketch/TestSketch.ino
...sketchbook_with_custom_hardware/TestSketch/TestSketch.ino
+0
-0
commands/testdata/sketchbook_with_custom_hardware/TestSketch/TestSketch.test.avr.testboard.hex
...tom_hardware/TestSketch/TestSketch.test.avr.testboard.hex
+0
-0
commands/testdata/sketchbook_with_custom_hardware/TestSketch2/TestSketch2.ino
...etchbook_with_custom_hardware/TestSketch2/TestSketch2.ino
+0
-0
commands/testdata/sketchbook_with_custom_hardware/hardware/test/avr/boards.txt
...tchbook_with_custom_hardware/hardware/test/avr/boards.txt
+25
-0
commands/testdata/sketchbook_with_custom_hardware/hardware/test/avr/platform.txt
...hbook_with_custom_hardware/hardware/test/avr/platform.txt
+13
-0
commands/testdata/sketchbook_with_custom_hardware/test.hex
commands/testdata/sketchbook_with_custom_hardware/test.hex
+1
-0
No files found.
commands/commands_test.go
View file @
443717fa
...
...
@@ -166,8 +166,90 @@ func makeTempSketchbookDir(t *testing.T) func() {
}
}
func
setSketchbookDir
(
t
*
testing
.
T
,
tmp
*
paths
.
Path
)
func
()
{
os
.
Setenv
(
"ARDUINO_SKETCHBOOK_DIR"
,
tmp
.
String
())
currSketchbookDir
=
tmp
fmt
.
Printf
(
"ARDUINO_SKETCHBOOK_DIR = %s
\n
"
,
os
.
Getenv
(
"ARDUINO_SKETCHBOOK_DIR"
))
return
func
()
{
os
.
Unsetenv
(
"ARDUINO_SKETCHBOOK_DIR"
)
currSketchbookDir
=
nil
fmt
.
Printf
(
"ARDUINO_SKETCHBOOK_DIR = %s
\n
"
,
os
.
Getenv
(
"ARDUINO_SKETCHBOOK_DIR"
))
}
}
// END -- Utility functions
func
TestUploadCommands
(
t
*
testing
.
T
)
{
defer
makeTempDataDir
(
t
)()
defer
useSharedDownloadDir
(
t
)()
defer
setSketchbookDir
(
t
,
paths
.
New
(
"testdata"
,
"sketchbook_with_custom_hardware"
))()
updateCoreIndex
(
t
)
exitCode
,
_
:=
executeWithArgs
(
t
,
"core"
,
"install"
,
"arduino:avr"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
// -i flag
exitCode
,
d
:=
executeWithArgs
(
t
,
"upload"
,
"-i"
,
currSketchbookDir
.
Join
(
"test.hex"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"QUIET"
)
require
.
Contains
(
t
,
string
(
d
),
"NOVERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/test.hex"
)
// -i flag with implicit extension
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
"-i"
,
currSketchbookDir
.
Join
(
"test"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"QUIET"
)
require
.
Contains
(
t
,
string
(
d
),
"NOVERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/test.hex"
)
// -i with absolute path
fullPath
,
err
:=
currSketchbookDir
.
Join
(
"test.hex"
)
.
Abs
()
require
.
NoError
(
t
,
err
,
"absolute path of test.hex"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
"-i"
,
fullPath
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"QUIET"
)
require
.
Contains
(
t
,
string
(
d
),
"NOVERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/test.hex"
)
// -v verbose
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
"-v"
,
"-i"
,
currSketchbookDir
.
Join
(
"test.hex"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"VERBOSE"
)
require
.
Contains
(
t
,
string
(
d
),
"NOVERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/test.hex"
)
// -t verify
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
"-t"
,
"-i"
,
currSketchbookDir
.
Join
(
"test.hex"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"QUIET"
)
require
.
Contains
(
t
,
string
(
d
),
"VERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/test.hex"
)
// -v -t verbose verify
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
"-v"
,
"-t"
,
"-i"
,
currSketchbookDir
.
Join
(
"test.hex"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"VERBOSE"
)
require
.
Contains
(
t
,
string
(
d
),
"VERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/test.hex"
)
// non-existent file
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
"-i"
,
currSketchbookDir
.
Join
(
"test123.hex"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
NotZero
(
t
,
exitCode
,
"exit code"
)
// sketch
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
currSketchbookDir
.
Join
(
"TestSketch"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"QUIET"
)
require
.
Contains
(
t
,
string
(
d
),
"NOVERIFY"
)
require
.
Contains
(
t
,
string
(
d
),
"testdata/sketchbook_with_custom_hardware/TestSketch/TestSketch.test.avr.testboard.hex"
)
// sketch without build
exitCode
,
d
=
executeWithArgs
(
t
,
"upload"
,
currSketchbookDir
.
Join
(
"TestSketch2"
)
.
String
(),
"-b"
,
"test:avr:testboard"
,
"-p"
,
"/dev/ttyACM0"
)
require
.
NotZero
(
t
,
exitCode
,
"exit code"
)
}
func
TestLibSearch
(
t
*
testing
.
T
)
{
defer
makeTempDataDir
(
t
)()
defer
makeTempSketchbookDir
(
t
)()
...
...
commands/testdata/sketchbook_with_custom_hardware/TestSketch/TestSketch.ino
0 → 100644
View file @
443717fa
commands/testdata/sketchbook_with_custom_hardware/TestSketch/TestSketch.test.avr.testboard.hex
0 → 100644
View file @
443717fa
commands/testdata/sketchbook_with_custom_hardware/TestSketch2/TestSketch2.ino
0 → 100644
View file @
443717fa
commands/testdata/sketchbook_with_custom_hardware/hardware/test/avr/boards.txt
0 → 100644
View file @
443717fa
testboard.name=Test Board
testboard.vid.0=0x2341
testboard.pid.0=0x8888
testboard.upload.tool=avrdude-none
testboard.upload.protocol=arduino
testboard.upload.maximum_size=32256
testboard.upload.maximum_data_size=2048
testboard.upload.speed=115200
testboard.bootloader.tool=avrdude
testboard.bootloader.low_fuses=0xFF
testboard.bootloader.high_fuses=0xDE
testboard.bootloader.extended_fuses=0xFD
testboard.bootloader.unlock_bits=0x3F
testboard.bootloader.lock_bits=0x0F
testboard.bootloader.file=optiboot/optiboot_atmega328.hex
testboard.build.mcu=atmega328p
testboard.build.f_cpu=16000000L
testboard.build.board=AVR_UNO
testboard.build.core=arduino:arduino
testboard.build.variant=standard
commands/testdata/sketchbook_with_custom_hardware/hardware/test/avr/platform.txt
0 → 100644
View file @
443717fa
name=Test AVR Boards
version=1.0.0
recipe.output.tmp_file={build.project_name}.hex
# Fake AVR programmer tool for testing
# ------------------------------------
tools.avrdude-none.upload.params.verbose=VERBOSE
tools.avrdude-none.upload.params.quiet=QUIET
tools.avrdude-none.upload.params.verify=VERIFY
tools.avrdude-none.upload.params.noverify=NOVERIFY
tools.avrdude-none.upload.pattern=echo {upload.verbose} {upload.verify} "{build.path}/{build.project_name}.hex"
commands/testdata/sketchbook_with_custom_hardware/test.hex
0 → 100644
View file @
443717fa
This is a fake .hex file for testing purposes
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