mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-24 16:51:34 +03:00
parent
d04cf1b1f3
commit
0841e7154f
@ -32,7 +32,7 @@ var locSchemes = []string{
|
||||
const stdDirective = cobra.ShellCompDirectiveNoSpace | cobra.ShellCompDirectiveKeepOrder
|
||||
|
||||
func TestCompleteAddLocation_Postgres(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
@ -268,7 +268,7 @@ func TestCompleteAddLocation_Postgres(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompleteAddLocation_SQLServer(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
@ -398,7 +398,7 @@ func TestCompleteAddLocation_SQLServer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompleteAddLocation_MySQL(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
@ -628,7 +628,7 @@ func TestCompleteAddLocation_MySQL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompleteAddLocation_SQLite3(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
@ -789,7 +789,7 @@ func TestCompleteAddLocation_SQLite3(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompleteAddLocation_History_Postgres(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
|
||||
@ -926,7 +926,7 @@ func TestCompleteAddLocation_History_Postgres(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompleteAddLocation_History_SQLServer(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
|
||||
@ -1127,7 +1127,7 @@ func TestCompleteAddLocation_History_SQLServer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompleteAddLocation_History_SQLite3(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
wd := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", wd)
|
||||
src3Loc := "sqlite3://" + wd + "/my.db?cache=FAST"
|
||||
@ -1302,7 +1302,7 @@ func TestParseLoc_stage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoCompleteAddLocationFile(t *testing.T) {
|
||||
tu.SkipWindows(t, "Shell completion not fully implemented for windows")
|
||||
tu.SkipIssueWindows(t, tu.GH372ShellCompletionWin)
|
||||
|
||||
absDir := tu.Chdir(t, filepath.Join("testdata", "add_location"))
|
||||
t.Logf("Working dir: %s", absDir)
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"github.com/neilotoole/sq/testh"
|
||||
"github.com/neilotoole/sq/testh/fixt"
|
||||
"github.com/neilotoole/sq/testh/sakila"
|
||||
"github.com/neilotoole/sq/testh/tu"
|
||||
)
|
||||
|
||||
func TestSmoke(t *testing.T) {
|
||||
@ -52,6 +53,7 @@ func TestSmoke(t *testing.T) {
|
||||
|
||||
func TestSakila_query(t *testing.T) {
|
||||
t.Parallel()
|
||||
tu.SkipIssueWindows(t, tu.GH355SQLiteDecimalWin)
|
||||
|
||||
testCases := []struct {
|
||||
file string
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/neilotoole/sq/libsq/core/lg"
|
||||
|
||||
"github.com/neilotoole/sq/libsq/core/lg/lga"
|
||||
"github.com/neilotoole/sq/libsq/core/lg/lgm"
|
||||
"github.com/neilotoole/sq/libsq/core/progress"
|
||||
|
@ -51,7 +51,7 @@ var sakilaSheets = []string{
|
||||
|
||||
func TestSakilaInspectSource(t *testing.T) {
|
||||
t.Parallel()
|
||||
tu.SkipWindows(t, "Skipping because of slow workflow perf on windows")
|
||||
tu.SkipIssueWindows(t, tu.GH371ExcelSlowWin)
|
||||
tu.SkipShort(t, true)
|
||||
|
||||
th := testh.New(t)
|
||||
@ -65,7 +65,7 @@ func TestSakilaInspectSource(t *testing.T) {
|
||||
|
||||
func TestSakilaInspectSheets(t *testing.T) {
|
||||
t.Parallel()
|
||||
tu.SkipWindows(t, "Skipping because of slow workflow perf on windows")
|
||||
tu.SkipIssueWindows(t, tu.GH371ExcelSlowWin)
|
||||
tu.SkipShort(t, true)
|
||||
|
||||
for _, sheet := range sakilaSheets {
|
||||
@ -85,7 +85,7 @@ func TestSakilaInspectSheets(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkInspectSheets(b *testing.B) {
|
||||
tu.SkipWindows(b, "Skipping because of slow workflow perf on windows")
|
||||
tu.SkipIssueWindows(b, tu.GH371ExcelSlowWin)
|
||||
tu.SkipShort(b, true)
|
||||
|
||||
for _, sheet := range sakilaSheets {
|
||||
@ -109,7 +109,7 @@ func BenchmarkInspectSheets(b *testing.B) {
|
||||
|
||||
func TestSakila_query_cmd(t *testing.T) {
|
||||
t.Parallel()
|
||||
tu.SkipWindows(t, "Skipping because of slow workflow perf on windows")
|
||||
tu.SkipIssueWindows(t, tu.GH371ExcelSlowWin)
|
||||
tu.SkipShort(t, true)
|
||||
|
||||
for _, sheet := range sakilaSheets {
|
||||
@ -131,7 +131,7 @@ func TestSakila_query_cmd(t *testing.T) {
|
||||
|
||||
func TestOpenFileFormats(t *testing.T) {
|
||||
t.Parallel()
|
||||
tu.SkipWindows(t, "Skipping because of slow workflow perf on windows")
|
||||
tu.SkipIssueWindows(t, tu.GH371ExcelSlowWin)
|
||||
tu.SkipShort(t, true)
|
||||
|
||||
testCases := []struct {
|
||||
@ -191,7 +191,7 @@ func TestOpenFileFormats(t *testing.T) {
|
||||
|
||||
func TestSakila_query(t *testing.T) {
|
||||
t.Parallel()
|
||||
tu.SkipWindows(t, "Skipping because of slow workflow perf on windows")
|
||||
tu.SkipIssueWindows(t, tu.GH371ExcelSlowWin)
|
||||
tu.SkipShort(t, true)
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -34,7 +34,7 @@ func TestSakila_SQL(t *testing.T) { //nolint:tparallel
|
||||
|
||||
// TestSakila_XLSX is a sanity check for Sakila XLSX test sources.
|
||||
func TestSakila_XLSX(t *testing.T) {
|
||||
tu.SkipWindows(t, "XLSX fails on windows pipeline (too slow)")
|
||||
tu.SkipIssueWindows(t, tu.GH371ExcelSlowWin)
|
||||
|
||||
handles := []string{sakila.XLSXSubset}
|
||||
// TODO: Add sakila.XLSX to handles when performance is reasonable
|
||||
|
78
testh/tu/skip.go
Normal file
78
testh/tu/skip.go
Normal file
@ -0,0 +1,78 @@
|
||||
package tu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// SkipShort skips t if testing.Short and arg skip are both true.
|
||||
func SkipShort(t testing.TB, skip bool) {
|
||||
if skip && testing.Short() {
|
||||
t.Skip("Skip long-running test because -short is true.")
|
||||
}
|
||||
}
|
||||
|
||||
// GHIssue is a GitHub issue number. It is used
|
||||
// with SkipIssue and SkipIssueWindows.
|
||||
type GHIssue uint
|
||||
|
||||
// String returns the URL of the GitHub issue.
|
||||
func (g GHIssue) String() string {
|
||||
return fmt.Sprintf("https://github.com/neilotoole/sq/issues/%d", g)
|
||||
}
|
||||
|
||||
const (
|
||||
GH355SQLiteDecimalWin GHIssue = 355 // https://github.com/neilotoole/sq/issues/355
|
||||
GH371ExcelSlowWin GHIssue = 371 // https://github.com/neilotoole/sq/issues/371
|
||||
GH372ShellCompletionWin GHIssue = 372 // https://github.com/neilotoole/sq/issues/372
|
||||
)
|
||||
|
||||
// SkipIssue skips t due to the specified GitHub issue.
|
||||
func SkipIssue(t testing.TB, issue GHIssue) {
|
||||
t.Skipf("Skip because of GitHub issue #%d: %s", issue, issue)
|
||||
}
|
||||
|
||||
const isWindows = runtime.GOOS == "windows"
|
||||
|
||||
// SkipIssueWindows skips t on windows due to the specified GitHub issue.
|
||||
func SkipIssueWindows(t testing.TB, issue GHIssue) {
|
||||
if !isWindows {
|
||||
return
|
||||
}
|
||||
|
||||
t.Skipf("Skip on Windows because of GitHub issue #%d: %s", issue, issue)
|
||||
}
|
||||
|
||||
// SkipIf skips t if b is true. If msgAndArgs is non-empty, its first
|
||||
// element must be a string, which can be a format string if there are
|
||||
// additional elements.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// tu.SkipIf(t, a == b)
|
||||
// tu.SkipIf(t, a == b, "skipping because a == b")
|
||||
// tu.SkipIf(t, a == b, "skipping because a is %v and b is %v", a, b)
|
||||
func SkipIf(t testing.TB, b bool, format string, args ...any) {
|
||||
if b {
|
||||
if format == "" {
|
||||
t.SkipNow()
|
||||
} else {
|
||||
t.Skipf(format, args...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SkipWindows skips t if running on Windows.
|
||||
func SkipWindows(t testing.TB, format string, args ...any) {
|
||||
if isWindows {
|
||||
t.Skipf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// SkipWindowsIf skips t if running on Windows and b is true.
|
||||
func SkipWindowsIf(t testing.TB, b bool, format string, args ...any) {
|
||||
if isWindows && b {
|
||||
t.Skipf(format, args...)
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode"
|
||||
@ -22,25 +21,6 @@ import (
|
||||
"github.com/neilotoole/sq/libsq/core/stringz"
|
||||
)
|
||||
|
||||
// SkipIff skips t if b is true. If msgAndArgs is non-empty, its first
|
||||
// element must be a string, which can be a format string if there are
|
||||
// additional elements.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// tu.SkipIff(t, a == b)
|
||||
// tu.SkipIff(t, a == b, "skipping because a == b")
|
||||
// tu.SkipIff(t, a == b, "skipping because a is %v and b is %v", a, b)
|
||||
func SkipIff(t testing.TB, b bool, format string, args ...any) {
|
||||
if b {
|
||||
if format == "" {
|
||||
t.SkipNow()
|
||||
} else {
|
||||
t.Skipf(format, args...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// StructFieldValue extracts the value of fieldName from arg strct.
|
||||
// If strct is nil, nil is returned.
|
||||
// The function will panic if strct is not a struct (or pointer to struct), or if
|
||||
@ -225,13 +205,6 @@ func Name(args ...any) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// SkipShort invokes t.Skip if testing.Short and arg skip are both true.
|
||||
func SkipShort(t testing.TB, skip bool) {
|
||||
if skip && testing.Short() {
|
||||
t.Skip("Skipping long-running test because -short is true.")
|
||||
}
|
||||
}
|
||||
|
||||
// AssertCompareFunc matches several of the testify/require funcs.
|
||||
// It can be used to choose assertion comparison funcs in test cases.
|
||||
type AssertCompareFunc func(require.TestingT, any, any, ...any)
|
||||
@ -339,20 +312,6 @@ func Chdir(t testing.TB, dir string) (absDir string) {
|
||||
return absDir
|
||||
}
|
||||
|
||||
// SkipWindows skips t if running on Windows.
|
||||
func SkipWindows(t testing.TB, format string, args ...any) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skipf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// SkipWindowsIf skips t if running on Windows and b is true.
|
||||
func SkipWindowsIf(t testing.TB, b bool, format string, args ...any) {
|
||||
if runtime.GOOS == "windows" && b {
|
||||
t.Skipf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// WriteTemp writes b to a temporary file. The pattern arg
|
||||
// is used to generate the file name, per os.CreateTemp.
|
||||
// If cleanup is true, the file is deleted on test cleanup.
|
||||
|
Loading…
Reference in New Issue
Block a user