Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea35293a1f |
@@ -58,9 +58,10 @@ func runCLI(opts *RunOptions) int {
|
|||||||
// runCLIWithLevel is runCLI that also returns the log level the run left
|
// runCLIWithLevel is runCLI that also returns the log level the run left
|
||||||
// set, read while runMu still keeps other runs from changing it. Each run
|
// set, read while runMu still keeps other runs from changing it. Each run
|
||||||
// starts at the default level, as a new process does. Before releasing the
|
// starts at the default level, as a new process does. Before releasing the
|
||||||
// lock it points the process-global logger at io.Discard: other tests log
|
// lock it points the process-global logger at io.Discard: test helpers also
|
||||||
// outside the lock (manifest loads, scans), and those lines must not land in
|
// log under runMu outside any run (manifest loads, scans), and those lines
|
||||||
// this run's buffers once it has returned and its test is reading them.
|
// must not land in this run's buffers once it has returned and its test is
|
||||||
|
// reading them.
|
||||||
func runCLIWithLevel(opts *RunOptions) (int, log.Level) {
|
func runCLIWithLevel(opts *RunOptions) (int, log.Level) {
|
||||||
runMu.Lock()
|
runMu.Lock()
|
||||||
defer runMu.Unlock()
|
defer runMu.Unlock()
|
||||||
@@ -206,13 +207,13 @@ func TestVersionFlagAndCommandMatch(t *testing.T) {
|
|||||||
|
|
||||||
// TestRootVerbosityFlags asserts that -q and -v given before any subcommand
|
// TestRootVerbosityFlags asserts that -q and -v given before any subcommand
|
||||||
// name take effect: in the root itself, and in the fetch and export
|
// name take effect: in the root itself, and in the fetch and export
|
||||||
// subcommands (issue #64). It does not run in parallel: other tests log
|
// subcommands (issue #64).
|
||||||
// outside runMu (manifest loads, scans), and a line logged while one of these
|
|
||||||
// runs is in progress lands in its output.
|
|
||||||
//
|
|
||||||
//nolint:paralleltest // see above
|
|
||||||
func TestRootVerbosityFlags(t *testing.T) {
|
func TestRootVerbosityFlags(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("quiet with no subcommand hides the banner", func(t *testing.T) {
|
t.Run("quiet with no subcommand hides the banner", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
loud := testOpts([]string{testApp}, afero.NewMemMapFs())
|
loud := testOpts([]string{testApp}, afero.NewMemMapFs())
|
||||||
require.Equal(t, 0, runCLI(loud))
|
require.Equal(t, 0, runCLI(loud))
|
||||||
assert.Contains(t, testStdout(t, loud), banner)
|
assert.Contains(t, testStdout(t, loud), banner)
|
||||||
@@ -224,6 +225,8 @@ func TestRootVerbosityFlags(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("quiet before fetch hides the banner", func(t *testing.T) {
|
t.Run("quiet before fetch hides the banner", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
opts := testOpts([]string{testApp, "-q", cmdFetch}, afero.NewMemMapFs())
|
opts := testOpts([]string{testApp, "-q", cmdFetch}, afero.NewMemMapFs())
|
||||||
|
|
||||||
assert.Equal(t, 1, runCLI(opts))
|
assert.Equal(t, 1, runCLI(opts))
|
||||||
@@ -232,6 +235,8 @@ func TestRootVerbosityFlags(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("verbose twice before fetch enables debug logging", func(t *testing.T) {
|
t.Run("verbose twice before fetch enables debug logging", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
opts := testOpts([]string{testApp, "-v", "-v", cmdFetch}, afero.NewMemMapFs())
|
opts := testOpts([]string{testApp, "-v", "-v", cmdFetch}, afero.NewMemMapFs())
|
||||||
|
|
||||||
assert.Equal(t, 1, runCLI(opts))
|
assert.Equal(t, 1, runCLI(opts))
|
||||||
@@ -239,6 +244,8 @@ func TestRootVerbosityFlags(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("quiet before export hides the manifest summary", func(t *testing.T) {
|
t.Run("quiet before export hides the manifest summary", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
manifest := buildTestManifest(t, map[string][]byte{"a.txt": []byte("a")})
|
manifest := buildTestManifest(t, map[string][]byte{"a.txt": []byte("a")})
|
||||||
require.NoError(t, afero.WriteFile(fs, testManifest, manifest, 0o644))
|
require.NoError(t, afero.WriteFile(fs, testManifest, manifest, 0o644))
|
||||||
|
|||||||
Reference in New Issue
Block a user