Skip to content

add TestData.String and use it for logging#54

Merged
RaduBerinde merged 1 commit intomasterfrom
testdata-string
Apr 7, 2025
Merged

add TestData.String and use it for logging#54
RaduBerinde merged 1 commit intomasterfrom
testdata-string

Conversation

@RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Apr 5, 2025

TestData.String() renders the entire testcase and we use it for better error and logging output.


This change is Reviewable

@RaduBerinde RaduBerinde requested review from Copilot, jbowens and tbg April 5, 2025 14:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • testdata/multiline: Language not supported
  • testdata/string: Language not supported

@RaduBerinde
Copy link
Member Author

Also added a t.Helper() so it shows the source which runs the datadriven test.

Since I'm here, would it help to indent the inputs/outputs and diffs? Current output:

    datadriven_test.go:389: 
        testdata/string:9:
        with some args=2
        input-line-1
        input-line-2
        ----
        with some args=2
        input-line-1
        input-line-2
    datadriven_test.go:389: 
        testdata/string:17:
        args that=1 render=(1, 2) differently=(1, 2, 3)
        input-line-1
        input-line-2
        ----
        args that=1 render=(1, 2) differently=(1, 2, 3)
        input-line-1
        input-line-2
    datadriven_test.go:389: 
        testdata/string:25:
        noinput
        ----
        noinput
    datadriven_test.go:389: 
        testdata/string:29:
        fail
        
        expected:
        foo
        
        found:
        fail

@RaduBerinde
Copy link
Member Author

Indented would look like this (looks more readable to me):

    datadriven_test.go:389: 
        testdata/string:9:
          with some args=2
          input-line-1
          input-line-2
          ----
          with some args=2
          input-line-1
          input-line-2
    datadriven_test.go:389: 
        testdata/string:17:
          args that=1 render=(1, 2) differently=(1, 2, 3)
          input-line-1
          input-line-2
          ----
          args that=1 render=(1, 2) differently=(1, 2, 3)
          input-line-1
          input-line-2
    datadriven_test.go:389: 
        testdata/string:25:
          noinput
          ----
          noinput
    datadriven_test.go:389: 
        testdata/string:29:
          fail
        
        expected:
          foo
        
        found:
          fail

@RaduBerinde RaduBerinde requested a review from yuzefovich April 7, 2025 15:23
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the proposed indentation.

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jbowens)

@RaduBerinde
Copy link
Member Author

TFTR! Added indentation.

`TestData.String()` renders the entire testcase and we use it for
better error and logging output. We also improve the logging output
using better indentation.
@RaduBerinde RaduBerinde merged commit f38a192 into master Apr 7, 2025
12 of 13 checks passed
@RaduBerinde RaduBerinde deleted the testdata-string branch April 7, 2025 16:46
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 this pull request may close these issues.

4 participants