github.com/hashicorp/go-plugin@v1.6.0/internal/cmdrunner/cmd_runner_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package cmdrunner 5 6 import ( 7 "os" 8 "path/filepath" 9 "strings" 10 "testing" 11 ) 12 13 func TestAdditionalNotesAboutCommand(t *testing.T) { 14 files := []string{ 15 "windows-amd64.exe", 16 "windows-386.exe", 17 "linux-amd64", 18 "darwin-amd64", 19 "darwin-arm64", 20 } 21 for _, file := range files { 22 fullFile := filepath.Join("testdata", file) 23 if _, err := os.Stat(fullFile); os.IsNotExist(err) { 24 t.Skipf("testdata executables not present; please run 'make' in testdata/ directory for this test") 25 } 26 27 notes := additionalNotesAboutCommand(fullFile) 28 if strings.Contains(file, "windows") && !strings.Contains(notes, "PE") { 29 t.Errorf("Expected notes to contain Windows information:\n%s", notes) 30 } 31 if strings.Contains(file, "linux") && !strings.Contains(notes, "ELF") { 32 t.Errorf("Expected notes to contain Linux information:\n%s", notes) 33 } 34 if strings.Contains(file, "darwin") && !strings.Contains(notes, "MachO") { 35 t.Errorf("Expected notes to contain macOS information:\n%s", notes) 36 } 37 38 if strings.Contains(file, "amd64") && !(strings.Contains(notes, "amd64") || strings.Contains(notes, "EM_X86_64") || strings.Contains(notes, "CpuAmd64")) { 39 t.Errorf("Expected notes to contain amd64 information:\n%s", notes) 40 } 41 42 if strings.Contains(file, "arm64") && !strings.Contains(notes, "CpuArm64") { 43 t.Errorf("Expected notes to contain arm64 information:\n%s", notes) 44 } 45 if strings.Contains(file, "386") && !strings.Contains(notes, "386") { 46 t.Errorf("Expected notes to contain 386 information:\n%s", notes) 47 } 48 49 } 50 }