-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Diagnose to runner.Runner interface (#275)
* Interface change but non-breaking as `runner.Runner` has not yet been tagged * Differentiate between empty line and closed channel * Maintain the previous first line of the error message just in case of consumers depending on it
- Loading branch information
Showing
13 changed files
with
150 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,50 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package cmdrunner | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestAdditionalNotesAboutCommand(t *testing.T) { | ||
files := []string{ | ||
"windows-amd64.exe", | ||
"windows-386.exe", | ||
"linux-amd64", | ||
"darwin-amd64", | ||
"darwin-arm64", | ||
} | ||
for _, file := range files { | ||
fullFile := filepath.Join("testdata", file) | ||
if _, err := os.Stat(fullFile); os.IsNotExist(err) { | ||
t.Skipf("testdata executables not present; please run 'make' in testdata/ directory for this test") | ||
} | ||
|
||
notes := additionalNotesAboutCommand(fullFile) | ||
if strings.Contains(file, "windows") && !strings.Contains(notes, "PE") { | ||
t.Errorf("Expected notes to contain Windows information:\n%s", notes) | ||
} | ||
if strings.Contains(file, "linux") && !strings.Contains(notes, "ELF") { | ||
t.Errorf("Expected notes to contain Linux information:\n%s", notes) | ||
} | ||
if strings.Contains(file, "darwin") && !strings.Contains(notes, "MachO") { | ||
t.Errorf("Expected notes to contain macOS information:\n%s", notes) | ||
} | ||
|
||
if strings.Contains(file, "amd64") && !(strings.Contains(notes, "amd64") || strings.Contains(notes, "EM_X86_64") || strings.Contains(notes, "CpuAmd64")) { | ||
t.Errorf("Expected notes to contain amd64 information:\n%s", notes) | ||
} | ||
|
||
if strings.Contains(file, "arm64") && !strings.Contains(notes, "CpuArm64") { | ||
t.Errorf("Expected notes to contain arm64 information:\n%s", notes) | ||
} | ||
if strings.Contains(file, "386") && !strings.Contains(notes, "386") { | ||
t.Errorf("Expected notes to contain 386 information:\n%s", notes) | ||
} | ||
|
||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
//go:build !windows | ||
// +build !windows | ||
|
||
package plugin | ||
package cmdrunner | ||
|
||
import ( | ||
"debug/elf" | ||
|
This file contains 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
//go:build windows | ||
// +build windows | ||
|
||
package plugin | ||
package cmdrunner | ||
|
||
import ( | ||
"debug/elf" | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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
File renamed without changes.
Oops, something went wrong.