Skip to content

Improve error message when port or fqbn flags are not set #523

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 2 commits into from
Dec 27, 2019
Merged
Changes from 1 commit
Commits
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
Redirect stderr for integration tests too
  • Loading branch information
federicobond committed Dec 19, 2019
commit b1a643f731794271722bcaa26fdd911c38b07fe7
13 changes: 8 additions & 5 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,28 @@ var (
// Redirecting stdOut so we can analyze output line by
// line and check with what we want.
stdOut = os.Stdout
stdErr = os.Stderr

currDownloadDir string
currDataDir string
currSketchbookDir string
)

type stdOutRedirect struct {
type outputRedirect struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

tempFile *os.File
}

func (grabber *stdOutRedirect) Open() {
func (grabber *outputRedirect) Open() {
tempFile, err := ioutil.TempFile(os.TempDir(), "test")
if err != nil {
panic("Opening temp output file")
}
os.Stdout = tempFile
os.Stderr = tempFile
grabber.tempFile = tempFile
}

func (grabber *stdOutRedirect) GetOutput() []byte {
func (grabber *outputRedirect) GetOutput() []byte {
_, err := grabber.tempFile.Seek(0, 0)
if err != nil {
panic("Rewinding temp output file")
Expand All @@ -76,13 +78,14 @@ func (grabber *stdOutRedirect) GetOutput() []byte {
return output
}

func (grabber *stdOutRedirect) Close() {
func (grabber *outputRedirect) Close() {
grabber.tempFile.Close()
err := os.Remove(grabber.tempFile.Name())
if err != nil {
panic("Removing temp output file")
}
os.Stdout = stdOut
os.Stderr = stdErr
}

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -135,7 +138,7 @@ func executeWithArgs(args ...string) (int, []byte) {

// This closure is here because we won't that the defer are executed after the end of the "executeWithArgs" method
func() {
redirect := &stdOutRedirect{}
redirect := &outputRedirect{}
redirect.Open()
// re-init feedback so it'll write to our grabber
feedback.SetDefaultFeedback(feedback.New(os.Stdout, os.Stdout, feedback.Text))
Expand Down