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(jasmine): transitive specs are no longer added to the test suite #2576

Merged

Conversation

a-ignatov-parc
Copy link
Contributor

@a-ignatov-parc a-ignatov-parc commented Mar 30, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Jasmine runner adds all transitive specs to active execution, which results in some specs running multiple times.

This can be especially problematic when there are multiple ts_projects with test specs that depend on each other. For example:

ts_project(name="proj_a") → jasmine_node_test(name="test_a") // will run specs from proj_a
↓
ts_project(name="proj_b") → jasmine_node_test(name="test_b") // will run specs from proj_a and proj_b
↓
ts_project(name="proj_c") → jasmine_node_test(name="test_c") // will run specs from proj_a, proj_b and proj_c

Issue Number: N/A

What is the new behavior?

Only specs from direct deps are added to active execution

Does this PR introduce a breaking change?

  • Yes, with opt-in flag
  • No

Other information

@@ -25,7 +25,7 @@ def _js_sources_impl(ctx):
depsets = []
for src in ctx.attr.srcs:
if JSModuleInfo in src:
depsets.append(src[JSModuleInfo].sources)
depsets.append(src[JSModuleInfo].direct_sources)
Copy link
Collaborator

Choose a reason for hiding this comment

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

technically this is a breaking change, since users who were relying on nested packages having their tests run will now just get nothing running those tests. I think maybe we have to hold this change for a 4.x branch, unless we want to add some opt-in flag for it.

Copy link
Contributor Author

@a-ignatov-parc a-ignatov-parc Mar 31, 2021

Choose a reason for hiding this comment

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

unless we want to add some opt-in flag for it.

I would prefer this option. Our tests are broken at the moment, so it would be great to get this fix faster than waiting for 4.x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the fix a bit:

  1. Added use_direct_specs opt-in flag.
  2. With this flag, only specs from direct sources of srcs will be added to execution. Specs from deps no longer taken into account.

@alexeagle
Copy link
Collaborator

after some thought I agree the old behavior is a bug

Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

nice, thanks!!

@alexeagle alexeagle merged commit e7eaf34 into bazel-contrib:stable Apr 6, 2021
@a-ignatov-parc a-ignatov-parc deleted the jasmine-fix-transitive-specs branch April 7, 2021 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants