mirror of https://github.com/databricks/cli.git
25 lines
532 B
Go
25 lines
532 B
Go
package testutil
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func RequireJDK(t *testing.T, ctx context.Context, version string) {
|
|
var stderr bytes.Buffer
|
|
|
|
cmd := exec.Command("javac", "-version")
|
|
cmd.Stderr = &stderr
|
|
err := cmd.Run()
|
|
require.NoError(t, err, "Unable to run javac -version")
|
|
|
|
// Get the first line of the output
|
|
line := strings.Split(stderr.String(), "\n")[0]
|
|
require.Contains(t, line, version, "Expected JDK version %s, got %s", version, line)
|
|
}
|