Skip to content
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

TestTextValueStyles test fails locally #81

Closed
dezren39 opened this issue Oct 31, 2023 · 4 comments
Closed

TestTextValueStyles test fails locally #81

dezren39 opened this issue Oct 31, 2023 · 4 comments

Comments

@dezren39
Copy link
Contributor

hello, i was working on a pr and noticed that these tests fail for me. i checked the github actions and the tests are green there. i've had this using windows and the vs code terminal, with powershell, pwsh, and cmd. i also had this issue with latest clean ubuntu wsl image from the store.
image

log on  empty-message-structured via 🐹 v1.21.3 took 2s
  ❯ git switch main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

log on  main [?] via 🐹 v1.21.3 
  ❯ go test        
--- FAIL: TestTextValueStyles (0.00s)
    --- FAIL: TestTextValueStyles/simple_message (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;86mINFO\x1b[0m info\n"
                                actual  : "INFO info\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -INFO info
                                +INFO info

                Test:           TestTextValueStyles/simple_message
    --- FAIL: TestTextValueStyles/message_with_keyvals (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;86mINFO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1mval1\x1b[0m \x1b[2mkey2\x1b[0m\x1b[2m=\x1b[0m\x1b[1mval2\x1b[0m\n"
                                actual  : "INFO info key1=val1 key2=val2\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -INFO info key1=val1 key2=val2
                                +INFO info key1=val1 key2=val2

                Test:           TestTextValueStyles/message_with_keyvals
    --- FAIL: TestTextValueStyles/error_message_with_multiline (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info\n  \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\n\x1b[2m  │ \x1b[0m\x1b[1mval1\x1b[0m\n\x1b[2m  │ \x1b[0m\x1b[1mval2\x1b[0m\n"
                                actual  : "ERRO info\n  key1=\n  │ val1\n  │ val2\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,5 +1,5 @@
                                -ERRO info
                                -  key1=
                                -  │ val1
                                -  │ val2
                                +ERRO info
                                +  key1=
                                +  │ val1
                                +  │ val2

                Test:           TestTextValueStyles/error_message_with_multiline
    --- FAIL: TestTextValueStyles/error_message_with_keyvals (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1mval1\x1b[0m \x1b[2mkey2\x1b[0m\x1b[2m=\x1b[0m\x1b[1mval2\x1b[0m\n"
                                actual  : "ERRO info key1=val1 key2=val2\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1=val1 key2=val2
                                +ERRO info key1=val1 key2=val2

                Test:           TestTextValueStyles/error_message_with_keyvals
    --- FAIL: TestTextValueStyles/odd_number_of_keyvals (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1mval1\x1b[0m \x1b[2mkey2\x1b[0m\x1b[2m=\x1b[0m\x1b[1mval2\x1b[0m \x1b[2mkey3\x1b[0m\x1b[2m=\x1b[0m\x1b[1;4;4m\"\x1b[0m\x1b[1;4;4mm\x1b[0m\x1b[1;4;4mi\x1b[0m\x1b[1;4;4ms\x1b[0m\x1b[1;4;4ms\x1b[0m\x1b[1;4;4mi\x1b[0m\x1b[1;4;4mn\x1b[0m\x1b[1;4;4mg\x1b[0m\x1b[4m \x1b[0m\x1b[1;4;4mv\x1b[0m\x1b[1;4;4ma\x1b[0m\x1b[1;4;4ml\x1b[0m\x1b[1;4;4mu\x1b[0m\x1b[1;4;4me\x1b[0m\x1b[1;4;4m\"\x1b[0m\n"
                                actual  : "ERRO info key1=val1 key2=val2 key3=\"missing value\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1=val1 key2=val2 key3="missing value"
                                +ERRO info key1=val1 key2=val2 key3="missing value"

                Test:           TestTextValueStyles/odd_number_of_keyvals
    --- FAIL: TestTextValueStyles/error_field (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"error value\"\x1b[0m\n"
                                actual  : "ERRO info key1=\"error value\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1="error value"
                                +ERRO info key1="error value"

                Test:           TestTextValueStyles/error_field
    --- FAIL: TestTextValueStyles/struct_field (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;86mINFO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m{foo:bar}\x1b[0m\n"
                                actual  : "INFO info key1={foo:bar}\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -INFO info key1={foo:bar}
                                +INFO info key1={foo:bar}

                Test:           TestTextValueStyles/struct_field
    --- FAIL: TestTextValueStyles/struct_field_quoted (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;86mINFO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"{foo:bar baz}\"\x1b[0m\n"
                                actual  : "INFO info key1=\"{foo:bar baz}\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -INFO info key1="{foo:bar baz}"
                                +INFO info key1="{foo:bar baz}"

                Test:           TestTextValueStyles/struct_field_quoted
    --- FAIL: TestTextValueStyles/slice_of_strings (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"[foo bar]\"\x1b[0m\n"
                                actual  : "ERRO info key1=\"[foo bar]\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1="[foo bar]"
                                +ERRO info key1="[foo bar]"

                Test:           TestTextValueStyles/slice_of_strings
    --- FAIL: TestTextValueStyles/slice_of_structs (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"[{foo:bar} {foo:baz}]\"\x1b[0m\n"
                                actual  : "ERRO info key1=\"[{foo:bar} {foo:baz}]\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1="[{foo:bar} {foo:baz}]"
                                +ERRO info key1="[{foo:bar} {foo:baz}]"

                Test:           TestTextValueStyles/slice_of_structs
    --- FAIL: TestTextValueStyles/slice_of_errors (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"[error value1 error value2]\"\x1b[0m\n"
                                actual  : "ERRO info key1=\"[error value1 error value2]\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1="[error value1 error value2]"
                                +ERRO info key1="[error value1 error value2]"

                Test:           TestTextValueStyles/slice_of_errors
    --- FAIL: TestTextValueStyles/map_of_strings (0.00s)
        text_test.go:397:
                Error Trace:    C:/Users/drewr/log/text_test.go:397
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"map[baz:qux foo:bar]\"\x1b[0m\n"
                                actual  : "ERRO info key1=\"map[baz:qux foo:bar]\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1="map[baz:qux foo:bar]"
                                +ERRO info key1="map[baz:qux foo:bar]"

                Test:           TestTextValueStyles/map_of_strings
FAIL
exit status 1
FAIL    github.com/charmbracelet/log    0.447s

log on  main [?] via 🐹 v1.21.3 took 2s
  ❯

log on  main [?] via 🐹 v1.21.3 
  ❯ cat .git/HEAD
ref: refs/heads/main

log on  main [?] via 🐹 v1.21.3 
  ❯ git rev-parse head
e5a733b643ab8926fbc58844217ff3c79bd07d97

log on  main [?] via 🐹 v1.21.3 
  ❯ go version        
go version go1.21.3 windows/amd64

log on  main [?] via 🐹 v1.21.3 
  ❯ git status        
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .history/
        .vscode/

nothing added to commit but untracked files present (use "git add" to track)

log on  main [?] via 🐹 v1.21.3 
  ❯ $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.8
PSEdition                      Core
GitCommitId                    7.3.8
OS                             Microsoft Windows 10.0.25393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


log on  main [?] via 🐹 v1.21.3 
@aymanbagabas
Copy link
Member

Could you try setting logger.SetColorProfile(termenv.TrueColor) in the tests?

@dezren39
Copy link
Contributor Author

dezren39 commented Nov 1, 2023

this produced the same effect. 😞

it's odd because the 'expected' shows up fully rendered in color and the log module works fine when i'm actually using it.

seems like something about the test setup but i'm unsure what it could be.

    --- FAIL: TestTextValueStyles/map_of_strings (0.00s)
        text_test.go:399:
                Error Trace:    C:/git/log/text_test.go:399
                Error:          Not equal:
                                expected: "\x1b[1;38;5;204mERRO\x1b[0m info \x1b[2mkey1\x1b[0m\x1b[2m=\x1b[0m\x1b[1m\"map[baz:qux foo:bar]\"\x1b[0m\n"
                                actual  : "ERRO info key1=\"map[baz:qux foo:bar]\"\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -ERRO info key1="map[baz:qux foo:bar]"
                                +ERRO info key1="map[baz:qux foo:bar]"

                Test:           TestTextValueStyles/map_of_strings
FAIL
exit status 1
FAIL    github.com/charmbracelet/log    0.383s
PS C:/git/log> git diff
diff --git a/text_test.go b/text_test.go
index 75c4bfc..3da6786 100644
--- a/text_test.go
+++ b/text_test.go
@@ -94,6 +94,8 @@ func TestTextCaller(t *testing.T) {
 func TestTextLogger(t *testing.T) {
        var buf bytes.Buffer
        logger := New(&buf)
+       logger.SetColorProfile(termenv.TrueColor)
+
        cases := []struct {
                name     string
                expected string
PS C:/git/log>

image
image

func TestTextLogger(t *testing.T) {
	var buf bytes.Buffer
	logger := New(&buf)
	logger.SetColorProfile(termenv.TrueColor)

	cases := []struct {

@dezren39
Copy link
Contributor Author

dezren39 commented Nov 1, 2023

oh nevermind i used the wrong test to update, tried again and that change worked. i will make a pr with this change, not sure if it's needed or a sign of a different issue, but will link to this once created.

@aymanbagabas
Copy link
Member

oh nevermind i used the wrong test to update, tried again and that change worked. i will make a pr with this change, not sure if it's needed or a sign of a different issue, but will link to this once created.

Thank you for confirming. This should be fixed in #84 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants