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

Enable Split By Test Example by default in RSpec #288

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

3v0k4
Copy link
Contributor

@3v0k4 3v0k4 commented Feb 17, 2025

Story

https://trello.com/c/xBllV4js/589-enable-sbte-by-default

Notice that SBTE is disabled for Turnip as it was never supported:

When using Turnip, you are supposed to run it with:

-r turnip/rspec

That monkey-patches RSpec defining Turnip::RSpec::Loader: https://github.com/jnicklas/turnip/blob/5eb4a21147b3758c81f369b163d1ae74b23cb0f0/lib/turnip/rspec.rb#L130

If SBTE was not disabled for Turnip, running KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true bundle exec rake "knapsack_pro:queue:rspec[-r turnip/rspec]" would fail to generate the JSON report because the RSpecTestExampleDetector shells out to RSpec w/o requiring Turnip.

mv .rspec .rspec.off
KNAPSACK_PRO_LOG_LEVEL=debug \
  KNAPSACK_PRO_ENDPOINT="http://api.knapsackpro.test:3000" \
  KNAPSACK_PRO_CI_NODE_TOTAL=2 \
  KNAPSACK_PRO_CI_NODE_INDEX=0 \
  KNAPSACK_PRO_CI_NODE_BUILD_ID="2025-01-18-001" \
  KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=a28ce51204d7c7dbd25c3352fea222cf \
  KNAPSACK_PRO_TEST_FILE_PATTERN="{spec/time_tracker_spec.rb}" \
  KNAPSACK_PRO_PROJECT_DIR=. \
  KNAPSACK_PRO_REPOSITORY_ADAPTER=git \
  bundle exec rake knapsack_pro:rspec
RSPEC_EXIT_CODE=$?
mv .rspec.off .rspec
exit $RSPEC_EXIT_CODE

# export KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true
# KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true \
# bundle exec rake "knapsack_pro:queue:rspec[-r turnip/rspec]"
# KNAPSACK_PRO_TEST_DIR=turnip \
# KNAPSACK_PRO_TEST_FILE_PATTERN="turnip/**/*.feature" \

Fails because Turnip being in the Gemfile is autorequired only as part of rails helper, but that test requires spec helper (and prolly even if it was rails helper it would happen too late.)

https://app.circleci.com/pipelines/github/KnapsackPro/knapsack_pro-ruby/1655/workflows/7621f513-9aef-42d9-962a-478d0aa19f43/jobs/25777

But the latest changes may fix this as the error is related to the time tracker not the generation at the beginning.

Checklist reminder

  • You added the changes to the UNRELEASED section of the CHANGELOG.md, including the needed bump (ie, patch, minor, major)
  • You follow the architecture outlined below for RSpec in Queue Mode, which is a work in progress (feel free to propose changes):
    • Pure: lib/knapsack_pro/pure/queue/rspec_pure.rb contains pure functions that are unit tested.
    • Extension: lib/knapsack_pro/extensions/rspec_extension.rb encapsulates calls to RSpec internals and is integration and e2e tested.
    • Runner: lib/knapsack_pro/runners/queue/rspec_runner.rb invokes the pure code and the extension to produce side effects, which are integration and e2e tested.

@3v0k4 3v0k4 self-assigned this Feb 17, 2025
@3v0k4 3v0k4 force-pushed the sbte branch 6 times, most recently from d84b1c4 to 8a911df Compare February 19, 2025 10:28
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.

1 participant