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

fix: replace hardcoded entry list with dynamically created one #6491

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

Conversation

timreichen
Copy link
Contributor

This PR removes the hardcoded entry list. Apparently some files were accidentally excluded by not updating the list.

Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.30%. Comparing base (48fae8f) to head (1dc58de).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6491   +/-   ##
=======================================
  Coverage   95.30%   95.30%           
=======================================
  Files         575      575           
  Lines       43279    43283    +4     
  Branches     6467     6467           
=======================================
+ Hits        41247    41251    +4     
  Misses       1993     1993           
  Partials       39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Nits. This could be a little over-engineered and contains other changes that don't pertain to the main objective of the PR.

Comment on lines +45 to +72
export function isTestFile(filePath: string): boolean {
if (!filePath.endsWith("test.ts")) return false;
const source = Deno.readTextFileSync(filePath);
const sourceFile = ts.createSourceFile(
filePath,
source,
ts.ScriptTarget.Latest,
);

let result = true;

function visitNode(node: ts.Node) {
if (!result) return;
if (
ts.isExportSpecifier(node) ||
ts.isExportAssignment(node) ||
ts.isExportDeclaration(node) ||
node.kind === ts.SyntaxKind.ExportKeyword
) {
result = false;
} else {
ts.forEachChild(node, visitNode);
}
}

visitNode(sourceFile);
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems extraneous. What about this?

export function isTestFile(filePath: string): boolean {
  return filePath.endsWith("test.ts");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole point of this function is to distinguish between test.ts which is used for testing (calling Deno.test()) and test.ts which is part of an api (like in @std/front-matter/test. This cannot be done by filename alone. I figured the best way was to check whether the file has exports or not, if so it must be part of an api.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe Deno.readTextFileSync(filePath).includes("\nDeno.test") would suffice? (leading \n ensures it's at the beginning of the line)

Copy link
Contributor Author

@timreichen timreichen Mar 19, 2025

Choose a reason for hiding this comment

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

This could lead to unintentional behaviour if Deno.test was wrapped in a function and therefore not at the beginning of the line (for example jsonc/testdata/JSONTestSuite/test.ts).
Also leads to unintentional behaviour when mentioned in a comment with unlucky line breaks:

/* bla bla bla...
Deno.test bla bla bla...
bla bla bla... */

So while this might work sometimes, it is not very robust.

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

Successfully merging this pull request may close these issues.

3 participants