-
-
Notifications
You must be signed in to change notification settings - Fork 2
Fix quit
message not being printed
#15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-task.md | ||
name: Test Go | ||
|
||
env: | ||
# See: https://github.com/actions/setup-go/tree/v2#readme | ||
GO_VERSION: "1.16" | ||
|
||
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows | ||
on: | ||
create: | ||
push: | ||
paths: | ||
- ".github/workflows/test-go-task.ya?ml" | ||
- "codecov.ya?ml" | ||
- "**/go.mod" | ||
- "**/go.sum" | ||
- "Taskfile.ya?ml" | ||
- "**.go" | ||
- "**/testdata/**" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/test-go-task.ya?ml" | ||
- "codecov.ya?ml" | ||
- "**/go.mod" | ||
- "**/go.sum" | ||
- "Taskfile.ya?ml" | ||
- "**.go" | ||
- "**/testdata/**" | ||
workflow_dispatch: | ||
repository_dispatch: | ||
|
||
jobs: | ||
run-determination: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
result: ${{ steps.determination.outputs.result }} | ||
steps: | ||
- name: Determine if the rest of the workflow should run | ||
id: determination | ||
run: | | ||
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" | ||
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. | ||
if [[ \ | ||
"${{ github.event_name }}" != "create" || \ | ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \ | ||
]]; then | ||
# Run the other jobs. | ||
RESULT="true" | ||
else | ||
# There is no need to run the other jobs. | ||
RESULT="false" | ||
fi | ||
echo "::set-output name=result::$RESULT" | ||
test: | ||
name: test (${{ matrix.module.path }} - ${{ matrix.operating-system }}) | ||
needs: run-determination | ||
if: needs.run-determination.outputs.result == 'true' | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
operating-system: | ||
- ubuntu-latest | ||
- windows-latest | ||
- macos-latest | ||
module: | ||
- path: ./ | ||
codecov-flags: unit | ||
|
||
runs-on: ${{ matrix.operating-system }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Run tests | ||
env: | ||
GO_MODULE_PATH: ${{ matrix.module.path }} | ||
run: task go:test | ||
|
||
- name: Send unit tests coverage to Codecov | ||
if: runner.os == 'Linux' | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
file: ${{ matrix.module.path }}coverage_unit.txt | ||
flags: ${{ matrix.module.codecov-flags }} | ||
fail_ci_if_error: ${{ github.repository == 'arduino/pluggable-discovery-protocol-handler' }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dist/ | ||
|
||
coverage_*.txt |
4 changes: 2 additions & 2 deletions
4
.licenses/pluggable-discovery-protocol-handler/go/github.com/arduino/go-paths-helper.dep.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...uggable-discovery-protocol-handler/go/github.com/arduino/go-properties-orderedmap.dep.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
.licenses/pluggable-discovery-protocol-handler/go/github.com/pkg/errors.dep.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: github.com/pkg/errors | ||
version: v0.9.1 | ||
type: go | ||
summary: Package errors provides simple error handling primitives. | ||
homepage: https://pkg.go.dev/github.com/pkg/errors | ||
license: bsd-2-clause | ||
licenses: | ||
- sources: LICENSE | ||
text: | | ||
Copyright (c) 2015, Dave Cheney <[email protected]> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
- sources: README.md | ||
text: BSD-2-Clause | ||
notices: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// This file is part of dummy-discovery. | ||
// | ||
// Copyright 2021 ARDUINO SA (http://www.arduino.cc/) | ||
// | ||
// This software is released under the GNU General Public License version 3, | ||
// which covers the main part of arduino-cli. | ||
// The terms of this license can be found at: | ||
// https://www.gnu.org/licenses/gpl-3.0.en.html | ||
// | ||
// You can be released from the requirements of the above licenses by purchasing | ||
// a commercial license. Buying such a license is mandatory if you want to modify or | ||
// otherwise use the software for commercial activities involving the Arduino | ||
// software without disclosing the source code of your own applications. To purchase | ||
// a commercial license, send an email to [email protected]. | ||
// | ||
|
||
package discovery | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/arduino/arduino-cli/executils" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func runDummyDiscovery(t *testing.T) *executils.Process { | ||
discoveryDir := "dummy-discovery" | ||
// Build dummy-discovery for testing | ||
builder, err := executils.NewProcess("go", "build") | ||
require.NoError(t, err) | ||
builder.SetDir(discoveryDir) | ||
require.NoError(t, builder.Run()) | ||
discovery, err := executils.NewProcess("./dummy-discovery") | ||
require.NoError(t, err) | ||
discovery.SetDir(discoveryDir) | ||
return discovery | ||
} | ||
|
||
func TestDiscoveryStdioHandling(t *testing.T) { | ||
discovery := runDummyDiscovery(t) | ||
|
||
stdout, err := discovery.StdoutPipe() | ||
require.NoError(t, err) | ||
stdin, err := discovery.StdinPipe() | ||
require.NoError(t, err) | ||
|
||
require.NoError(t, discovery.Start()) | ||
defer discovery.Kill() | ||
|
||
n, err := stdin.Write([]byte("quit\n")) | ||
require.Greater(t, n, 0) | ||
require.NoError(t, err) | ||
output := [1024]byte{} | ||
// require.NoError(t, discovery.Wait()) | ||
n, err = stdout.Read(output[:]) | ||
require.Greater(t, n, 0) | ||
require.NoError(t, err) | ||
|
||
expectedOutput := "{\n \"eventType\": \"quit\",\n \"message\": \"OK\"\n}\n" | ||
require.Equal(t, expectedOutput, string(output[:n])) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dummy-discovery | ||
dummy-discovery.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about dropping the channel + goroutine + waitgroup +
d.quit
in change of a mutex?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be mean refactor everything again, I'd prefer to avoid that. 😖