Skip to content

Conversation

@gabritto
Copy link
Member

Noticed in #2040 that we were treating all fourslash tests which we currently diff as submodule tests. This PR makes it so we only treat tests in the /gen and /manual subfolders as submodule tests, since that's where the ported tests should go.

@gabritto gabritto marked this pull request as ready for review November 12, 2025 18:21
}

func isSubmoduleTest(testPath string) bool {
return strings.Contains(testPath, "fourslash/tests/gen") || strings.Contains(testPath, "fourslash/tests/manual")
Copy link
Member

Choose a reason for hiding this comment

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

I was worried about this, but runtime.Callers always returns fourward slash paths, so it should work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hadn't really thought about that, but I tested on Windows. 🙂

Copilot finished reviewing on behalf of gabritto November 12, 2025 18:24
Copy link
Contributor

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.

Pull Request Overview

This PR fixes the classification of fourslash tests to correctly distinguish between submodule tests (from TypeScript repository) and local tests. Previously, all fourslash tests were treated as submodule tests, but only those in the /gen and /manual subfolders should be. The PR uses runtime caller information to determine the test file path and categorize it appropriately.

Key Changes

  • Uses runtime.Caller(1) to obtain test file path at test creation time
  • Implements path-based logic to identify submodule tests (those containing /gen or /manual in path)
  • Updates baseline generation to skip diff creation for non-submodule tests

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
internal/fourslash/fourslash.go Captures test path using runtime.Caller and passes it to baseline verification
internal/fourslash/baselineutil.go Adds isSubmoduleTest function and conditionally sets baseline options based on test path
testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline.diff Removes diff baseline for local test
testdata/baselines/reference/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline Adds proper baseline for local test (non-submodule)

Comment on lines +237 to +239
func isSubmoduleTest(testPath string) bool {
return strings.Contains(testPath, "fourslash/tests/gen") || strings.Contains(testPath, "fourslash/tests/manual")
}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The path matching using strings.Contains could produce false positives if 'fourslash/tests/gen' or 'fourslash/tests/manual' appears elsewhere in the absolute path (e.g., in a user's directory name). Consider using filepath.Base(filepath.Dir(testPath)) or a more robust path matching approach like checking if the path ends with these patterns or using path separators for more precise matching.

Copilot uses AI. Check for mistakes.
@gabritto gabritto added this pull request to the merge queue Nov 12, 2025
Merged via the queue into main with commit 35a5221 Nov 12, 2025
28 checks passed
@gabritto gabritto deleted the gabritto/nodiff branch November 12, 2025 18:52
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.

3 participants