Skip to content

Move all tests to ./tests/ with new Go module to isolate testing dependencies #58

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

endigma
Copy link

@endigma endigma commented Apr 29, 2025

Summary

  • Moves tests into tests/ package, which is its own go module, to isolate testing dependencies from the main package
    • This makes it an easier decision to include litter in independent, downstream testing packages similar to testify, which was previously an indirect dependency of litter itself
    • It can confuse users when they install a testify alternative and it pulls in testify indirectly
    • This also caused litter to indirectly import its own alternative, spew, via testify
    • Also allows tests to freely import essentially any 3rd party package to add tests when an issue is resolved to prevent regressions
  • Uses assert.Equal instead of the diff shellout, which may be uglier but is more reliable, was making a fuss about trailing newlines or something I didn't want to debug

runTestWithCfg(t, name, &standardCfg, cases...)
}

func diffStrings(t *testing.T, expected, actual string) (*string, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

To be clear, it was very intentional to use diff here. assert.Equal() produces super unreadable unified diffs. If you want different output, I'd be fine with an environment variable to control it (defaulting to diff).

Copy link
Author

Choose a reason for hiding this comment

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

Reverted, fwiw the pure go diff is a lot faster

tests/go.mod Outdated
@@ -0,0 +1,16 @@
module github.com/sanity-io/litter/tests

go 1.23.7
Copy link
Member

Choose a reason for hiding this comment

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

Might as well use latest (1.24.0?) and also update the root go.mod?

Copy link
Author

@endigma endigma Apr 30, 2025

Choose a reason for hiding this comment

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

Updated in tests module, shouldn't update the main one unless necessary, libraries automatically get compiled with the version of their consumer, this is a minimum, and litter doesn't use any >1.16 features so I don't see why you'd break it for no reason

@endigma endigma requested a review from atombender April 30, 2025 20:39
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.

2 participants