mirror of https://github.com/databricks/cli.git
Support extending tests with custom replacements
This commit is contained in:
parent
ad6045c001
commit
8d98d87b58
|
@ -190,6 +190,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
|
|||
}
|
||||
|
||||
repls.SetPathWithParents(tmpDir, "$TMPDIR")
|
||||
repls.Repls = append(repls.Repls, config.Repls...)
|
||||
|
||||
scriptContents := readMergedScriptContents(t, dir)
|
||||
testutil.WriteFile(t, filepath.Join(tmpDir, EntryPointScript), scriptContents)
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/databricks/cli/libs/testdiff"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -24,6 +25,10 @@ type TestConfig struct {
|
|||
// Which OSes the test is enabled on. Each string is compared against runtime.GOOS.
|
||||
// If absent, default to true.
|
||||
GOOS map[string]bool
|
||||
|
||||
// List of additional replacements to apply on this test.
|
||||
// Old is a regexp, New is a replacement expression.
|
||||
Repls []testdiff.Replacement
|
||||
}
|
||||
|
||||
// FindConfig finds the closest config file.
|
||||
|
|
|
@ -28,3 +28,8 @@ $TMPDIR/subdir/a/b/c
|
|||
|
||||
=== Custom output files - everything starting with out is captured and compared
|
||||
>>> echo HELLO
|
||||
|
||||
=== Custom regex can be specified in [[Repl]] section
|
||||
1234
|
||||
CUSTOM_NUMBER_REGEX
|
||||
123456
|
||||
|
|
|
@ -19,3 +19,8 @@ trace withdir subdir/a/b/c python3 -c 'import os; print(os.getcwd())' | sed 's/\
|
|||
|
||||
printf "\n=== Custom output files - everything starting with out is captured and compared"
|
||||
trace echo HELLO > out.hello.txt
|
||||
|
||||
printf "\n=== Custom regex can be specified in [[Repl]] section\n"
|
||||
echo 1234
|
||||
echo 12345
|
||||
echo 123456
|
||||
|
|
Loading…
Reference in New Issue