Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
874d2e2
testsuite: Added helper functions to handle test envs
cmaglie Jul 12, 2022
dae3242
testsuite: Added helper functions to run arduino-cli
cmaglie Jul 12, 2022
9679f1c
testsuite: Added colored output to arduino-cli Run helper
cmaglie Jul 12, 2022
46c381e
testsuite: Pass cli config through env variables
cmaglie Jul 12, 2022
9ae6760
testsuite: added env commands to download and extract files
cmaglie Jul 13, 2022
1465a20
testsuite: added commands to start cli daemon and run some gRPC calls
cmaglie Jul 13, 2022
f53c673
testsuite: moved test harness inside 'internal' package
cmaglie Jul 13, 2022
82e98ee
testsuite: added first daemon test for gRPC board watch
cmaglie Jul 13, 2022
b453bca
testsuite: added http server helper
cmaglie Jul 28, 2022
db39fb0
testsuite: added JSON helpers
cmaglie Jul 29, 2022
f2c886e
testsuite: Added possibility to use shared download staging folder
cmaglie Jul 29, 2022
1ab2ef4
testsuite: Converted a core_test.py test (WIP)
cmaglie Jul 29, 2022
eac1356
REMOVEME: Deactivate daemon integration test for now
cmaglie Jul 29, 2022
2631e96
testsuite: force colored output
cmaglie Jul 29, 2022
330b51d
testsuite: moved all generic subroutines into their own library
cmaglie Aug 1, 2022
b886381
testsuite: moved daemon test in his own dir
cmaglie Aug 1, 2022
a9d73c2
fixed typo
cmaglie Aug 1, 2022
f3c1463
testsuite: added some helpers to improve daemon testing
cmaglie Aug 1, 2022
94ba9ac
testsuite: added test for #1614
cmaglie Aug 1, 2022
688f7af
Removed converted test
cmaglie Aug 2, 2022
9fea578
testsuite: perform build before test
cmaglie Aug 2, 2022
0c282cd
Added missing comment
cmaglie Aug 2, 2022
55833f8
Renamed test file
cmaglie Aug 2, 2022
eea3ec9
Skip failing tests
cmaglie Aug 2, 2022
ca557ac
Updated licensed cache
cmaglie Aug 2, 2022
a929ff7
re-enable test for fixed bug
cmaglie Aug 2, 2022
1953902
testsuite: disable postinstall
cmaglie Aug 3, 2022
0896f4c
Removed useless startDaemon
cmaglie Aug 5, 2022
f21e86c
Renamed inst -> grpcInst
cmaglie Aug 5, 2022
d977ffe
Close daemon gRPC connection on test cleanup
cmaglie Aug 5, 2022
82e47d3
Added comment
cmaglie Aug 5, 2022
87561fe
Apply suggestions from code review
cmaglie Aug 8, 2022
757fa06
Update internal/integrationtest/arduino-cli.go
cmaglie Aug 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
testsuite: moved all generic subroutines into their own library
  • Loading branch information
cmaglie committed Aug 5, 2022
commit 330b51d82079dc71a64d3d148d7ba7c1ed4e3341
9 changes: 5 additions & 4 deletions arduino/discovery/discovery_client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,17 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand All @@ -314,6 +314,7 @@ go.bug.st/downloader/v2 v2.1.1/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13R
go.bug.st/relaxed-semver v0.9.0/go.mod h1:ug0/W/RPYUjliE70Ghxg77RDHmPxqpo7SHV16ijss7Q=
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
Expand Down
7 changes: 4 additions & 3 deletions client_example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand All @@ -296,6 +296,7 @@ go.bug.st/downloader/v2 v2.1.1/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13R
go.bug.st/relaxed-semver v0.9.0/go.mod h1:ug0/W/RPYUjliE70Ghxg77RDHmPxqpo7SHV16ijss7Q=
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
Expand Down
9 changes: 5 additions & 4 deletions docsgen/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,18 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand All @@ -372,6 +372,7 @@ go.bug.st/serial v1.3.2 h1:6BFZZd/wngoL5PPYYTrFUounF54SIkykHpT98eq6zvk=
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45 h1:mACY1anK6HNCZtm/DK2Rf2ZPHggVqeB0+7rY9Gl6wyI=
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
Expand Down
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
github.com/spf13/cobra v1.2.1
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.0
go.bug.st/cleanup v1.0.0
go.bug.st/downloader/v2 v2.1.1
go.bug.st/relaxed-semver v0.9.0
Expand All @@ -57,10 +57,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/itchyny/gojq v0.12.8
github.com/tidwall/gjson v1.14.1
)
require go.bug.st/testsuite v0.0.1

require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
Expand All @@ -71,6 +68,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/itchyny/gojq v0.12.8 // indirect
github.com/itchyny/timefmt-go v0.1.3 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -90,8 +88,6 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
Expand Down
13 changes: 6 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -345,21 +345,18 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand All @@ -377,6 +374,8 @@ go.bug.st/serial v1.3.2 h1:6BFZZd/wngoL5PPYYTrFUounF54SIkykHpT98eq6zvk=
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45 h1:mACY1anK6HNCZtm/DK2Rf2ZPHggVqeB0+7rY9Gl6wyI=
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
go.bug.st/testsuite v0.0.1 h1:sdB+u46r+9ZVqROU1fl5utU773HktWDSc4hz6/jPK6A=
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
Expand Down
14 changes: 8 additions & 6 deletions internal/integrationtest/arduino-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/arduino/go-paths-helper"
"github.com/fatih/color"
"github.com/stretchr/testify/require"
"go.bug.st/testsuite"
"google.golang.org/grpc"
)

Expand All @@ -53,18 +54,19 @@ type ArduinoCLIConfig struct {
}

// NewArduinoCliWithinEnvironment creates a new Arduino CLI client inside the given environment.
func NewArduinoCliWithinEnvironment(t *testing.T, config *ArduinoCLIConfig, env *Environment) *ArduinoCLI {
func NewArduinoCliWithinEnvironment(env *testsuite.Environment, config *ArduinoCLIConfig) *ArduinoCLI {
color.NoColor = false
cli := NewArduinoCli(t, config)
staging := env.downloadsDir
cli := NewArduinoCli(env.T(), config)
staging := env.SharedDownloadsDir()
if !config.UseSharedStagingFolder {
staging = env.Root().Join("arduino15/staging")
staging = env.RootDir().Join("arduino15/staging")
}
cli.cliEnvVars = []string{
fmt.Sprintf("ARDUINO_DATA_DIR=%s", env.Root().Join("arduino15")),
fmt.Sprintf("ARDUINO_DATA_DIR=%s", env.RootDir().Join("arduino15")),
fmt.Sprintf("ARDUINO_DOWNLOADS_DIR=%s", staging),
fmt.Sprintf("ARDUINO_SKETCHBOOK_DIR=%s", env.Root().Join("Arduino")),
fmt.Sprintf("ARDUINO_SKETCHBOOK_DIR=%s", env.RootDir().Join("Arduino")),
}
env.RegisterCleanUpCallback(cli.CleanUp)
return cli
}

Expand Down
8 changes: 4 additions & 4 deletions internal/integrationtest/arduino-cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ import (
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
"go.bug.st/testsuite"
)

func TestArduinoCliDaemon(t *testing.T) {
t.Skip("Deactivated for now")
t.SkipNow()

env := NewEnvironment(t)
env := testsuite.NewEnvironment(t)
defer env.CleanUp()

cli := NewArduinoCliWithinEnvironment(t, &ArduinoCLIConfig{
cli := NewArduinoCliWithinEnvironment(env, &ArduinoCLIConfig{
ArduinoCLIPath: paths.New("..", "..", "arduino-cli"),
UseSharedStagingFolder: true,
}, env)
defer cli.CleanUp()
})

_, _, err := cli.Run("core", "update-index")
require.NoError(t, err)
Expand Down
65 changes: 14 additions & 51 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@
package core_test

import (
"encoding/json"
"fmt"
"strings"
"testing"

"github.com/arduino/arduino-cli/internal/integrationtest"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"
"go.bug.st/testsuite"
"go.bug.st/testsuite/requirejson"
)

func TestCoreSearch(t *testing.T) {
env := integrationtest.NewEnvironment(t)
env := testsuite.NewEnvironment(t)
defer env.CleanUp()

cli := integrationtest.NewArduinoCliWithinEnvironment(t, &integrationtest.ArduinoCLIConfig{
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
UseSharedStagingFolder: true,
}, env)
defer cli.CleanUp()
})

// Set up an http server to serve our custom index file
test_index := paths.New("..", "testdata", "test_index.json")
url, httpClose := integrationtest.HTTPServeFile(t, 8000, test_index)
defer httpClose()
url := env.HTTPServeFile(8000, test_index)

// Run update-index with our test index
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
Expand All @@ -53,47 +51,22 @@ func TestCoreSearch(t *testing.T) {

out, _, err = cli.Run("core", "search", "avr", "--format", "json")
require.NoError(t, err)
data := make([]interface{}, 0)
require.NoError(t, json.Unmarshal(out, &data))
require.NotEmpty(t, data)
// same check using gjson lib
require.NotEmpty(t, gjson.ParseBytes(out).Array())
requirejson.NotEmpty(t, out)

// additional URL
out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err)
require.NoError(t, json.Unmarshal(out, &data))
require.Len(t, data, 1)
requirejson.Len(t, out, 1)

// show all versions
out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err)
require.NoError(t, json.Unmarshal(out, &data))
require.Len(t, data, 2)
// alternative check using gjson:
require.Len(t, gjson.ParseBytes(out).Array(), 2)
// alternative using gojq:
integrationtest.JQQuery(t, out, "length", 2)
requirejson.Len(t, out, 2)
// requirejson.Len(t, out, 3) // Test failure

checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) {
// Alternative solution with gojq
jqquery := fmt.Sprintf(`contains( [{id:"%s", latest:"%s"}] )`, id, version)
integrationtest.JQQuery(t, out, jqquery, true, "platform %s@%s is missing from the output", id, version)

// Alternative solution with gjson
// query := fmt.Sprintf("#(id=%s)#|#(latest=%s)", id, version)
// if gjson.ParseBytes(out).Get(query).Exists() {
// return
// }
// require.FailNowf(t, "Wrong output", "platform %s@%s is missing from the output", id, version)

// Alternative solution:
// for _, platform := range gjson.ParseBytes(out).Array() {
// if platform.Get("id").Str == id && platform.Get("latest").Str == version {
// return
// }
// }
// require.FailNowf(t, "Wrong output", "platform %s@%s is missing from the output", id, version)
jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version)
requirejson.Contains(t, out, jqquery, "platform %s@%s is missing from the output", id, version)
}

// Search all Retrokit platforms
Expand Down Expand Up @@ -127,20 +100,10 @@ func TestCoreSearch(t *testing.T) {
out, _, err := cli.Run(args...)
require.NoError(t, err)

// Alternative solution with gojq
for _, id := range expectedIDs {
jqquery := fmt.Sprintf(`contains( [{id:"%s"}] )`, id)
integrationtest.JQQuery(t, out, jqquery, true, "platform %s is missing from the output", id)
jqquery := fmt.Sprintf(`[{id:"%s"}]`, id)
requirejson.Contains(t, out, jqquery, "platform %s is missing from the output", id)
}

// Alternative solution with gjson
// data := gjson.ParseBytes(out)
// for _, expectedID := range expectedIDs {
// query := fmt.Sprintf("#(id=%s)", expectedID)
// if !data.Get(query).Exists() {
// require.FailNowf(t, "Wrong output", "platform %s is missing from the output", expectedID)
// }
// }
}

runSearch("mkr1000", "arduino:samd")
Expand Down
Loading