-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce Output in Atmos Tests #923
Open
Cerebrovinny
wants to merge
17
commits into
main
Choose a base branch
from
DEV-2909
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−29
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e570c04
added verbose option tests
Cerebrovinny 8d18254
output fixes wip
Cerebrovinny ec59f97
test workflow improvements
Cerebrovinny 28e8c98
test workflow improvements
Cerebrovinny 8c1d398
test verbosity
Cerebrovinny ae09de3
test verbosity
Cerebrovinny 6e062b1
Add test verbosity control and validate logs-level flag
Cerebrovinny 1c73119
Remove test command from acceptance tests workflow
Cerebrovinny cb57324
Replace go-test-action with make testacc for acceptance tests
Cerebrovinny d60334d
Add verbose test option and set quiet mode for CI tests
Cerebrovinny 7998437
Add go-test-action and simplify test workflow
Cerebrovinny 9580b73
refactor: update acceptance test workflow to use test-command parameter
Cerebrovinny bfcf44f
test verbosity
Cerebrovinny 71aa4b4
add test action for testing
Cerebrovinny bdfa19c
add test action for testing
Cerebrovinny 3d82560
add back testacc
Cerebrovinny 0eb8bbe
revert log changes in cli test
Cerebrovinny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,17 @@ version-windows: build-windows | |
deps: | ||
go mod download | ||
|
||
# Run acceptance tests | ||
testacc: get | ||
go test $(TEST) -v $(TESTARGS) -timeout 2m | ||
# Test verbosity levels: quiet, normal, verbose | ||
TEST_VERBOSITY ?= normal | ||
|
||
.PHONY: testacc | ||
testacc: ## Run all tests | ||
@if [ "$(TEST_VERBOSITY)" = "quiet" ]; then \ | ||
ATMOS_TEST_VERBOSITY=$(TEST_VERBOSITY) go test ./... -timeout 20m; \ | ||
elif [ "$(TEST_VERBOSITY)" = "verbose" ]; then \ | ||
ATMOS_TEST_VERBOSITY=$(TEST_VERBOSITY) go test -v -count=1 ./... -timeout 20m; \ | ||
else \ | ||
ATMOS_TEST_VERBOSITY=$(TEST_VERBOSITY) go test -v ./... -timeout 20m; \ | ||
fi | ||
Comment on lines
+60
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what benefit this translation brings. Why not just set the variable needed, rather than translate it? |
||
|
||
.PHONY: lint get build version build-linux build-windows build-macos deps version-linux version-windows version-macos testacc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestVerbosity controls the verbosity level of test output | ||
type TestVerbosity int | ||
|
||
const ( | ||
// TestVerbosityQuiet minimal output, only failures | ||
TestVerbosityQuiet TestVerbosity = iota | ||
// TestVerbosityNormal standard test output | ||
TestVerbosityNormal | ||
// TestVerbosityVerbose detailed test output | ||
TestVerbosityVerbose | ||
) | ||
|
||
var ( | ||
// DefaultTestVerbosity is the default verbosity level for tests | ||
DefaultTestVerbosity = TestVerbosityNormal | ||
// Store descriptions to avoid repetition | ||
printedDescriptions = make(map[string]bool) | ||
) | ||
|
||
// GetTestVerbosity returns the current test verbosity level | ||
func GetTestVerbosity() TestVerbosity { | ||
verbStr := os.Getenv("ATMOS_TEST_VERBOSITY") | ||
switch verbStr { | ||
case "quiet": | ||
return TestVerbosityQuiet | ||
case "verbose": | ||
return TestVerbosityVerbose | ||
default: | ||
return DefaultTestVerbosity | ||
} | ||
} | ||
|
||
// TestLogf logs a message during test execution based on verbosity level | ||
func TestLogf(t *testing.T, minVerbosity TestVerbosity, format string, args ...interface{}) { | ||
if GetTestVerbosity() >= minVerbosity { | ||
t.Logf(format, args...) | ||
} | ||
} | ||
|
||
// TestLog logs a message during test execution based on verbosity level | ||
func TestLog(t *testing.T, minVerbosity TestVerbosity, args ...interface{}) { | ||
if GetTestVerbosity() >= minVerbosity { | ||
t.Log(args...) | ||
} | ||
} | ||
|
||
// LogTestDescription logs a test description only once to avoid repetition | ||
func LogTestDescription(t *testing.T, description string) { | ||
if description == "" { | ||
return | ||
} | ||
|
||
// Create a unique key for the description to avoid repetition within the same test | ||
key := fmt.Sprintf("%s-%s", t.Name(), description) | ||
if !printedDescriptions[key] { | ||
if GetTestVerbosity() == TestVerbosityQuiet { | ||
t.Logf("Test Description: %s", description) | ||
} else { | ||
t.Logf("\nTest Description: %s", description) | ||
} | ||
printedDescriptions[key] = true | ||
} | ||
} | ||
|
||
// LogTestFailure logs detailed failure information based on verbosity | ||
func LogTestFailure(t *testing.T, description string, expected, actual interface{}, extraInfo ...string) { | ||
LogTestDescription(t, description) | ||
|
||
verbosity := GetTestVerbosity() | ||
if verbosity == TestVerbosityQuiet { | ||
t.Errorf("Expected: %v\nGot: %v", expected, actual) | ||
} else { | ||
t.Errorf("\nExpected: %v\nGot: %v", expected, actual) | ||
if len(extraInfo) > 0 && verbosity >= TestVerbosityNormal { | ||
t.Logf("Additional Info:\n%s", strings.Join(extraInfo, "\n")) | ||
} | ||
} | ||
} | ||
|
||
// AssertTestResult is a wrapper for testify/assert that respects verbosity | ||
func AssertTestResult(t *testing.T, assertion func() bool, description string, msgAndArgs ...interface{}) bool { | ||
result := assertion() | ||
if !result { | ||
LogTestDescription(t, description) | ||
return assert.True(t, result, msgAndArgs...) | ||
} | ||
if GetTestVerbosity() >= TestVerbosityVerbose { | ||
LogTestDescription(t, description) | ||
return assert.True(t, result, msgAndArgs...) | ||
} | ||
return result | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a lot of tests were unintentionally deleted from this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that to test the output of robherley/go-test-action@v0 in actions, its added back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw this is not very good, not able to make it work properly so for now I recommend we stick with our main tests only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what it refers to.