KnapsackPro / knapsack_pro-ruby

Knapsack Pro gem splits tests across parallel CI nodes and makes sure that tests run in optimal time
https://knapsackpro.com
MIT License
132 stars 27 forks source link

Deselect tests to run #57

Closed eddbrown closed 6 years ago

eddbrown commented 6 years ago

Hey there!

You can selectively run some tests by specifying their directory, but is there a way to deselect some tests and keep the others using minitest?

Thanks!

ArturT commented 6 years ago

You can pass any configuration to minitest this way: https://github.com/KnapsackPro/knapsack_pro-ruby#passing-arguments-to-minitest

$ bundle exec rake "knapsack_pro:minitest[--arg_name value]"

How do you deselect some tests right now with minitest?

What problem do you want to solve?

eddbrown commented 6 years ago

Thanks for the reply! The specific problem:

I have a folder called 'test' in the rails app where all the tests live. However, there is a folder inside called 'test/system' that contains tests that I do not always want circle to run. As such, I would like to ignore running tests in that folder. I was wondering if there is a way through knapsack to do that.

ArturT commented 6 years ago

You can explicitly whitelist all folders in test directory with KNAPSACK_PRO_TEST_FILE_PATTERN environment variable:

KNAPSACK_PRO_TEST_FILE_PATTERN="{test/controllers,test/models}/**{,/*/**}/*_test.rb" \ 
  KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=api_key_for_minitest \
  KNAPSACK_PRO_REPOSITORY_ADAPTER=git \
  KNAPSACK_PRO_PROJECT_DIR=~/ruby-project-repo \
  KNAPSACK_PRO_CI_NODE_TOTAL=2} \
  KNAPSACK_PRO_CI_NODE_INDEX=1 \
  bundle exec rake knapsack_pro:minitest[--verbose]

In above example only tests from folders test/controllers and test/models will be run.

You can provide any pattern that works with Dir.glob method https://ruby-doc.org/core-2.5.0/Dir.html#method-c-glob

Here is documentation for KNAPSACK_PRO_TEST_FILE_PATTERN https://github.com/KnapsackPro/knapsack_pro-ruby#how-can-i-run-tests-from-multiple-directories

Hope this helps. :)

Do you have an account on https://knapsackpro.com ? I can take a look at your CI build metrics to ensure your test suite works fine.

ArturT commented 6 years ago

@eddbrown I added exclude pattern in this PR https://github.com/KnapsackPro/knapsack_pro-ruby/pull/72 and I've just released a new version of knapsack_pro gem.

Here is documentation for exclude pattern: