Skip to content

refactor: test utils functions by removing redundant test instructions parsing and simplifying asserting functions #1374

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

Merged
merged 1 commit into from
May 24, 2025

Conversation

chavacava
Copy link
Collaborator

Avoids parsing instructions twice and simplifies signature of asserting functions

  1. Original code parsed test instructions twice:
	if parseInstructions(t, fullFilePath, src) == nil {   // first parsing
		assertSuccess(t, baseDir, stat, []lint.Rule{rule}, c)
		return
	}
	assertFailures(t, baseDir, stat, src, []lint.Rule{rule}, c) // second parsing inside assertFailures
  1. Functions assertSuccess and assertFailures both took baseDir string, fi os.FileInfo as arguments to do exactly the same file path reconstruction that callers already do. Simplified both to receive the file path.

@chavacava chavacava merged commit 7b38dd8 into master May 24, 2025
8 checks passed
@chavacava chavacava deleted the refactor-test-utils branch May 26, 2025 11:19
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