New Upstream Snapshot - ruby-knapsack
Ready changes
Summary
Merged new upstream version: 4.0.0+git20221031.1.f824140 (was: 1.18.0).
Resulting package
Built on 2023-01-19T21:11 (took 12m0s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots ruby-knapsack
Lintian Result
Diff
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index ffb20e6..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,23 +0,0 @@
-*.gem
-*.rbc
-.bundle
-.config
-.yardoc
-Gemfile.lock
-InstalledFiles
-_yardoc
-coverage
-doc/
-lib/bundler/man
-pkg
-rdoc
-spec/reports
-test/tmp
-test/version_tmp
-tmp
-*.bundle
-*.so
-*.o
-*.a
-mkmf.log
-.idea/
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index fb5d13b..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,116 +0,0 @@
----
-sudo: false
-language: ruby
-rvm:
- - 1.9.3
- - 2.0.0
- - 2.1
- - 2.2
- - 2.3
- - 2.4
- - 2.5
- - 2.6
-addons:
- code_climate:
- repo_token: 38686058eed480dd0fcf8bce9015733e0bae88e44e30f4a1ac63df8aec2f86d8
-before_install:
- - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
-script:
- # Test for knapsack gem
- - bin/print_header.sh "Run specs for Knapsack gem"
- - bundle exec rspec spec
-
-
- - bin/print_header.sh "------------------------------------------------------"
-
-
- # Tests for example rspec test suite
- - bin/print_header.sh "Generate knapsack report"
- - KNAPSACK_GENERATE_REPORT=true bundle exec rspec --default-path spec_examples --tag focus
-
- - bin/print_header.sh "Run specs with enabled time offset warning"
- - bundle exec rspec --default-path spec_examples
-
- - bin/print_header.sh "Run rake task for the first CI node"
- - CI_NODE_TOTAL=2 CI_NODE_INDEX=0 KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
- - bin/print_header.sh "Run rake task for the second CI node"
- - CI_NODE_TOTAL=2 CI_NODE_INDEX=1 KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
-
- - bin/print_header.sh "Check passing arguments to rspec. Run only specs with custom_focus tag"
- - KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake "knapsack:rspec[--tag custom_focus]"
- - KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bin/knapsack rspec "--tag custom_focus --profile"
-
- - bin/print_header.sh "Run specs with custom knapsack logger"
- - CUSTOM_LOGGER=true KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
-
- - bin/print_header.sh "Run specs for custom knapsack report path"
- - cp knapsack_rspec_report.json knapsack_custom_rspec_report.json
- - KNAPSACK_REPORT_PATH="knapsack_custom_rspec_report.json" KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
-
- - bin/print_header.sh "Run specs when spec file was removed and still exists in knapsack report json"
- - rm spec_examples/fast/1_spec.rb
- - KNAPSACK_TEST_FILE_PATTERN="spec_examples/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
-
- - bin/print_header.sh "Run specs from multiple directories with manually specified test_dir"
- - KNAPSACK_TEST_DIR=spec_examples KNAPSACK_TEST_FILE_PATTERN="{spec_examples,spec_engine_examples}/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
-
-
- - bin/print_header.sh "------------------------------------------------------"
-
-
- # Tests for example minitest test suite
- - bin/print_header.sh "Generate knapsack report"
- - KNAPSACK_GENERATE_REPORT=true bundle exec rake test
-
- - bin/print_header.sh "Run tests with enabled time offset warning"
- - bundle exec rake test
-
- - bin/print_header.sh "Run rake task for the first CI node"
- - CI_NODE_TOTAL=2 CI_NODE_INDEX=0 KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake knapsack:minitest
- - bin/print_header.sh "Run rake task for the second CI node"
- - CI_NODE_TOTAL=2 CI_NODE_INDEX=1 KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake knapsack:minitest
-
- - bin/print_header.sh "Check passing arguments to minitest. Run verbose tests"
- - KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake "knapsack:minitest[--verbose]"
- - if [ "$TRAVIS_RUBY_VERSION" == "1.9.3" ]; then KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bin/knapsack minitest "--verbose"; fi
- - if [ "$TRAVIS_RUBY_VERSION" != "1.9.3" ]; then KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bin/knapsack minitest "--verbose --pride"; fi
-
- - bin/print_header.sh "Run tests with custom knapsack logger"
- - CUSTOM_LOGGER=true KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake knapsack:minitest
-
- - bin/print_header.sh "Run tests for custom knapsack report path"
- - cp knapsack_minitest_report.json knapsack_custom_minitest_report.json
- - KNAPSACK_REPORT_PATH="knapsack_custom_minitest_report.json" KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake knapsack:minitest
-
- - bin/print_header.sh "Run tests when test file was removed and still exists in knapsack report json"
- - rm test_examples/fast/unit_test.rb
- - KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake knapsack:minitest
-
-
- - bin/print_header.sh "------------------------------------------------------"
-
-
- # Tests for example spinach test suite
- - bin/print_header.sh "Generate knapsack report"
- - KNAPSACK_GENERATE_REPORT=true bundle exec spinach -f spinach_examples
-
- - bin/print_header.sh "Run tests with enabled time offset warning"
- - bundle exec spinach -f spinach_examples
-
- - bin/print_header.sh "Run rake task for the first CI node"
- - CI_NODE_TOTAL=2 CI_NODE_INDEX=0 KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
- - bin/print_header.sh "Run rake task for the second CI node"
- - CI_NODE_TOTAL=2 CI_NODE_INDEX=1 KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
-
- - bin/print_header.sh "Run tests with custom knapsack logger"
- - CUSTOM_LOGGER=true KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
-
- - bin/print_header.sh "Run tests for custom knapsack report path"
- - cp knapsack_spinach_report.json knapsack_custom_spinach_report.json
- - KNAPSACK_REPORT_PATH="knapsack_custom_spinach_report.json" KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
-
- - bin/print_header.sh "Run tests when test file was removed and still exists in knapsack report json"
- - rm spinach_examples/scenario1.feature
- - KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
-notifications:
- email: false
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24af1a2..132f2d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,13 +2,98 @@
* TODO
+### 4.0.0
+
+* __(breaking change)__ Remove support for RSpec 2.x. This change was already done by accident in [the pull request](https://github.com/KnapsackPro/knapsack/pull/107) when we added the RSpec `context` hook, which is available only since RSpec 3.x.
+* Use RSpec `example` block argument instead of the global `RSpec.current_example`. This allows to run tests with the `async-rspec` gem.
+
+ https://github.com/KnapsackPro/knapsack/pull/117
+
+https://github.com/KnapsackPro/knapsack/compare/v3.1.0...v4.0.0
+
+### 3.1.0
+
+* Sorting Algorithm: round robin to least connections
+
+ https://github.com/KnapsackPro/knapsack/pull/99
+
+https://github.com/KnapsackPro/knapsack/compare/v3.0.0...v3.1.0
+
+### 3.0.0
+
+* __(breaking change)__ Require minimum Ruby 2.2 version
+
+ https://github.com/KnapsackPro/knapsack/pull/115
+
+* __(breaking change)__ Drop support for Minitest 4.x. Force to use minitest 5.x even on CI.
+
+ https://github.com/KnapsackPro/knapsack/pull/114
+
+* Replace Travis CI with GitHub Actions
+
+ https://github.com/KnapsackPro/knapsack/pull/112
+
+https://github.com/KnapsackPro/knapsack/compare/v2.0.0...v3.0.0
+
+### 2.0.0
+
+* __(breaking change)__ Ruby 2.1 is a minimum required version
+
+ https://github.com/KnapsackPro/knapsack/pull/113
+
+* Use Ruby 3 and add small development adjustments in codebase
+
+ https://github.com/KnapsackPro/knapsack/pull/110
+
+https://github.com/KnapsackPro/knapsack/compare/v1.22.0...v2.0.0
+
+### 1.22.0
+
+* Update time offset warning
+
+ https://github.com/KnapsackPro/knapsack/pull/105
+
+https://github.com/KnapsackPro/knapsack/compare/v1.21.1...v1.22.0
+
+### 1.21.1
+
+* Fix a bug with tracking time for pending specs in RSpec
+
+ https://github.com/KnapsackPro/knapsack/pull/109
+
+https://github.com/KnapsackPro/knapsack/compare/v1.21.0...v1.21.1
+
+### 1.21.0
+
+* Track time in before and after `:context` hooks
+
+ https://github.com/KnapsackPro/knapsack/pull/107
+
+https://github.com/KnapsackPro/knapsack/compare/v1.20.0...v1.21.0
+
+### 1.20.0
+
+* Use `Process.clock_gettime` to measure track execution time
+
+ https://github.com/KnapsackPro/knapsack/pull/100
+
+https://github.com/KnapsackPro/knapsack/compare/v1.19.0...v1.20.0
+
+### 1.19.0
+
+* Add support for Bitbucket Pipelines
+
+ https://github.com/KnapsackPro/knapsack/pull/97
+
+https://github.com/KnapsackPro/knapsack/compare/v1.18.0...v1.19.0
+
### 1.18.0
* Add support for Semaphore 2.0
- https://github.com/ArturT/knapsack/pull/92
+ https://github.com/KnapsackPro/knapsack/pull/92
-https://github.com/ArturT/knapsack/compare/v1.17.2...v1.18.0
+https://github.com/KnapsackPro/knapsack/compare/v1.17.2...v1.18.0
### 1.17.2
@@ -17,65 +102,65 @@ https://github.com/ArturT/knapsack/compare/v1.17.2...v1.18.0
* Add info about Knapsack Pro Queue Mode in knapsack output
* Update URL to FAQ in knapsack output
- https://github.com/ArturT/knapsack/pull/90
+ https://github.com/KnapsackPro/knapsack/pull/90
-https://github.com/ArturT/knapsack/compare/v1.17.1...v1.17.2
+https://github.com/KnapsackPro/knapsack/compare/v1.17.1...v1.17.2
### 1.17.1
* Fix RSpec signal handling by replacing process
- https://github.com/ArturT/knapsack/pull/86
+ https://github.com/KnapsackPro/knapsack/pull/86
-https://github.com/ArturT/knapsack/compare/v1.17.0...v1.17.1
+https://github.com/KnapsackPro/knapsack/compare/v1.17.0...v1.17.1
### 1.17.0
* Add support for GitLab CI ENV variable `CI_NODE_INDEX` starting from 1.
- https://github.com/ArturT/knapsack/pull/83
+ https://github.com/KnapsackPro/knapsack/pull/83
-https://github.com/ArturT/knapsack/compare/v1.16.0...v1.17.0
+https://github.com/KnapsackPro/knapsack/compare/v1.16.0...v1.17.0
### 1.16.0
* Add support for Ruby >= 1.9.3.
- https://github.com/ArturT/knapsack/pull/77
+ https://github.com/KnapsackPro/knapsack/pull/77
-https://github.com/ArturT/knapsack/compare/v1.15.0...v1.16.0
+https://github.com/KnapsackPro/knapsack/compare/v1.15.0...v1.16.0
### 1.15.0
* Add support for Cucumber 3.
- https://github.com/ArturT/knapsack/pull/68
+ https://github.com/KnapsackPro/knapsack/pull/68
-https://github.com/ArturT/knapsack/compare/v1.14.1...v1.15.0
+https://github.com/KnapsackPro/knapsack/compare/v1.14.1...v1.15.0
### 1.14.1
* Update RSpec timing adapter to be more resilient.
- https://github.com/ArturT/knapsack/pull/64
+ https://github.com/KnapsackPro/knapsack/pull/64
-https://github.com/ArturT/knapsack/compare/v1.14.0...v1.14.1
+https://github.com/KnapsackPro/knapsack/compare/v1.14.0...v1.14.1
### 1.14.0
* Moves Timecop to development dependency.
- https://github.com/ArturT/knapsack/pull/61
+ https://github.com/KnapsackPro/knapsack/pull/61
-https://github.com/ArturT/knapsack/compare/v1.13.3...v1.14.0
+https://github.com/KnapsackPro/knapsack/compare/v1.13.3...v1.14.0
### 1.13.3
* Fix: Trailing slash should be removed from allocator test_dir.
- https://github.com/ArturT/knapsack/issues/57
+ https://github.com/KnapsackPro/knapsack/issues/57
-https://github.com/ArturT/knapsack/compare/v1.13.2...v1.13.3
+https://github.com/KnapsackPro/knapsack/compare/v1.13.2...v1.13.3
### 1.13.2
@@ -84,78 +169,78 @@ https://github.com/ArturT/knapsack/compare/v1.13.2...v1.13.3
Related:
https://github.com/KnapsackPro/knapsack_pro-ruby/issues/27
-https://github.com/ArturT/knapsack/compare/v1.13.1...v1.13.2
+https://github.com/KnapsackPro/knapsack/compare/v1.13.1...v1.13.2
### 1.13.1
* Fix: Get rid of call #zero? method on $?.exitstatus in test runners tasks
- https://github.com/ArturT/knapsack/pull/52
+ https://github.com/KnapsackPro/knapsack/pull/52
-https://github.com/ArturT/knapsack/compare/v1.13.0...v1.13.1
+https://github.com/KnapsackPro/knapsack/compare/v1.13.0...v1.13.1
### 1.13.0
* Add KNAPSACK_LOG_LEVEL option
- https://github.com/ArturT/knapsack/pull/49
+ https://github.com/KnapsackPro/knapsack/pull/49
-https://github.com/ArturT/knapsack/compare/v1.12.2...v1.13.0
+https://github.com/KnapsackPro/knapsack/compare/v1.12.2...v1.13.0
### 1.12.2
* Fix support for turnip >= 2.x
- https://github.com/ArturT/knapsack/pull/47
+ https://github.com/KnapsackPro/knapsack/pull/47
-https://github.com/ArturT/knapsack/compare/v1.12.1...v1.12.2
+https://github.com/KnapsackPro/knapsack/compare/v1.12.1...v1.12.2
### 1.12.1
* Cucumber and Spinach should load files from proper folder in case when you use custom test directory.
-https://github.com/ArturT/knapsack/compare/v1.12.0...v1.12.1
+https://github.com/KnapsackPro/knapsack/compare/v1.12.0...v1.12.1
### 1.12.0
* Add support for Minitest::SharedExamples
- https://github.com/ArturT/knapsack/pull/46
+ https://github.com/KnapsackPro/knapsack/pull/46
-https://github.com/ArturT/knapsack/compare/v1.11.1...v1.12.0
+https://github.com/KnapsackPro/knapsack/compare/v1.11.1...v1.12.0
### 1.11.1
* Require spinach in spec helper so tests will pass but don't require it in spinach adapter because it breaks for users who don't use spinach and they don't want to add it to their Gemfile
Related PR:
- https://github.com/ArturT/knapsack/pull/41
+ https://github.com/KnapsackPro/knapsack/pull/41
-https://github.com/ArturT/knapsack/compare/v1.11.0...v1.11.1
+https://github.com/KnapsackPro/knapsack/compare/v1.11.0...v1.11.1
### 1.11.0
* Add support for Spinach
- https://github.com/ArturT/knapsack/pull/41
+ https://github.com/KnapsackPro/knapsack/pull/41
-https://github.com/ArturT/knapsack/compare/v1.10.0...v1.11.0
+https://github.com/KnapsackPro/knapsack/compare/v1.10.0...v1.11.0
### 1.10.0
* Log the time offset warning at INFO if time not exceeded
- https://github.com/ArturT/knapsack/pull/40
+ https://github.com/KnapsackPro/knapsack/pull/40
-https://github.com/ArturT/knapsack/compare/v1.9.0...v1.10.0
+https://github.com/KnapsackPro/knapsack/compare/v1.9.0...v1.10.0
### 1.9.0
* Use Knapsack.logger for runner output
- https://github.com/ArturT/knapsack/pull/39
+ https://github.com/KnapsackPro/knapsack/pull/39
-https://github.com/ArturT/knapsack/compare/v1.8.0...v1.9.0
+https://github.com/KnapsackPro/knapsack/compare/v1.8.0...v1.9.0
### 1.8.0
@@ -163,15 +248,15 @@ https://github.com/ArturT/knapsack/compare/v1.8.0...v1.9.0
https://github.com/KnapsackPro/knapsack_pro-ruby/issues/5
-https://github.com/ArturT/knapsack/compare/v1.7.0...v1.8.0
+https://github.com/KnapsackPro/knapsack/compare/v1.7.0...v1.8.0
### 1.7.0
* Add ability to run tests from multiple directories
- https://github.com/ArturT/knapsack/pull/35
+ https://github.com/KnapsackPro/knapsack/pull/35
-https://github.com/ArturT/knapsack/compare/v1.6.1...v1.7.0
+https://github.com/KnapsackPro/knapsack/compare/v1.6.1...v1.7.0
### 1.6.1
@@ -179,106 +264,106 @@ https://github.com/ArturT/knapsack/compare/v1.6.1...v1.7.0
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/4
-https://github.com/ArturT/knapsack/compare/v1.6.0...v1.6.1
+https://github.com/KnapsackPro/knapsack/compare/v1.6.0...v1.6.1
### 1.6.0
* Add support for Cucumber 2
- https://github.com/ArturT/knapsack/issues/30
+ https://github.com/KnapsackPro/knapsack/issues/30
-https://github.com/ArturT/knapsack/compare/v1.5.1...v1.6.0
+https://github.com/KnapsackPro/knapsack/compare/v1.5.1...v1.6.0
### 1.5.1
* Add link to FAQ at the end of time offset warning
-https://github.com/ArturT/knapsack/compare/v1.5.0...v1.5.1
+https://github.com/KnapsackPro/knapsack/compare/v1.5.0...v1.5.1
### 1.5.0
* Add support for snap-ci.com
-https://github.com/ArturT/knapsack/compare/v1.4.1...v1.5.0
+https://github.com/KnapsackPro/knapsack/compare/v1.4.1...v1.5.0
### 1.4.1
-* Update test file pattern in tests also. Related PR https://github.com/ArturT/knapsack/pull/27
+* Update test file pattern in tests also. Related PR https://github.com/KnapsackPro/knapsack/pull/27
* Ensure there are no duplicates in leftover tests because of new test file pattern
-https://github.com/ArturT/knapsack/compare/v1.4.0...v1.4.1
+https://github.com/KnapsackPro/knapsack/compare/v1.4.0...v1.4.1
### 1.4.0
* Rename RspecAdapter to RSpecAdapter so that it is consistent
- https://github.com/ArturT/knapsack/pull/28
+ https://github.com/KnapsackPro/knapsack/pull/28
* Change file path patterns to support 1-level symlinks by default
- https://github.com/ArturT/knapsack/pull/27
+ https://github.com/KnapsackPro/knapsack/pull/27
-https://github.com/ArturT/knapsack/compare/v1.3.4...v1.4.0
+https://github.com/KnapsackPro/knapsack/compare/v1.3.4...v1.4.0
### 1.3.4
* Make knapsack backwards compatible with earlier version of minitest
- https://github.com/ArturT/knapsack/pull/26
+ https://github.com/KnapsackPro/knapsack/pull/26
-https://github.com/ArturT/knapsack/compare/v1.3.3...v1.3.4
+https://github.com/KnapsackPro/knapsack/compare/v1.3.3...v1.3.4
### 1.3.3
* Fix wrong dependency for timecop
-https://github.com/ArturT/knapsack/compare/v1.3.2...v1.3.3
+https://github.com/KnapsackPro/knapsack/compare/v1.3.2...v1.3.3
### 1.3.2
* Use Timecop as dependency and always use Time.now_without_mock_time to avoid problem when someone did stub on Time without using Timecop.
* Don't exit on successful RSpec and Cucumber runs
- https://github.com/ArturT/knapsack/pull/25
+ https://github.com/KnapsackPro/knapsack/pull/25
-https://github.com/ArturT/knapsack/compare/v1.3.1...v1.3.2
+https://github.com/KnapsackPro/knapsack/compare/v1.3.1...v1.3.2
### 1.3.1
* Treat KNAPSACK_GENERATE_REPORT=false as generate_report -> false
- https://github.com/ArturT/knapsack/pull/22
+ https://github.com/KnapsackPro/knapsack/pull/22
-https://github.com/ArturT/knapsack/compare/v1.3.0...v1.3.1
+https://github.com/KnapsackPro/knapsack/compare/v1.3.0...v1.3.1
### 1.3.0
* Add knapsack binary
- https://github.com/ArturT/knapsack/pull/21
+ https://github.com/KnapsackPro/knapsack/pull/21
-https://github.com/ArturT/knapsack/compare/v1.2.1...v1.3.0
+https://github.com/KnapsackPro/knapsack/compare/v1.2.1...v1.3.0
### 1.2.1
* Add support for Turnip features
- https://github.com/ArturT/knapsack/pull/19
+ https://github.com/KnapsackPro/knapsack/pull/19
-https://github.com/ArturT/knapsack/compare/v1.2.0...v1.2.1
+https://github.com/KnapsackPro/knapsack/compare/v1.2.0...v1.2.1
### 1.2.0
* Add minitest adapter.
* Fix bug with missing global time execution when tests took less than second.
-https://github.com/ArturT/knapsack/compare/v1.1.1...v1.2.0
+https://github.com/KnapsackPro/knapsack/compare/v1.1.1...v1.2.0
### 1.1.1
* Use `system` instead of `exec` in rake tasks so we can return exit code from command.
-https://github.com/ArturT/knapsack/compare/v1.1.0...v1.1.1
+https://github.com/KnapsackPro/knapsack/compare/v1.1.0...v1.1.1
### 1.1.0
@@ -288,15 +373,15 @@ https://github.com/ArturT/knapsack/compare/v1.1.0...v1.1.1
* Pull request #12 - Raise error when CI_NODE_INDEX >= CI_NODE_TOTAL
- https://github.com/ArturT/knapsack/pull/12
+ https://github.com/KnapsackPro/knapsack/pull/12
### 1.0.3
* Fix bug #11 - Track properly time when using Timecop gem in tests.
- https://github.com/ArturT/knapsack/issues/11
+ https://github.com/KnapsackPro/knapsack/issues/11
- https://github.com/ArturT/knapsack/issues/9
+ https://github.com/KnapsackPro/knapsack/issues/9
### 1.0.2
diff --git a/README.md b/README.md
index 67b6e0b..62d193d 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,36 @@
-# [Open README](http://docs.knapsackpro.com/ruby/knapsack)
+# knapsack gem
+
+Knapsack splits tests evenly across parallel CI nodes to run fast CI build and save you time.
+
+| | knapsack gem | knapsack_pro gem |
+| -------------------------------------------- | ------------ | ---------------- |
+| __Is free__ | ✓ Yes | ✓ Yes, [free plan](https://knapsackpro.com?utm_source=github&utm_medium=readme&utm_campaign=knapsack_gem&utm_content=free_plan) |
+| __Regular Mode - a static tests split__ | ✓ Yes | ✓ Yes |
+| __Queue Mode - a dynamic tests split__ <br>([ensures all CI nodes finish work at the same time](https://docs.knapsackpro.com/2020/how-to-speed-up-ruby-and-javascript-tests-with-ci-parallelisation)) | No | ✓ Yes |
+| __Auto [split slow RSpec test file](https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it) between parallel CI nodes__ <br>(a single test file can be auto split by test examples between parallel jobs) | No | ✓ Yes |
+| Tracking tests timing per commit, branch | No | ✓ Yes |
+| Support for other programming languages | No | ✓ Yes |
+| Support for CI providers | limited | ✓ Yes |
+| __Installation README__ | [Install README](http://docs.knapsackpro.com/ruby/knapsack) | [Install README](https://docs.knapsackpro.com/integration/) |
+
+[Features of knapsack vs knapsack_pro Ruby gem](https://knapsackpro.com/features/ruby_knapsack_pro_vs_knapsack?utm_source=github&utm_medium=readme&utm_campaign=knapsack_gem&utm_content=ruby_knapsack_pro_vs_knapsack)
+
+# Do you use Heroku?
+
+Do you know Knapsack Pro Ruby gem is available as Heroku add-on? It works with your current CI server.
+https://elements.heroku.com/addons/knapsack-pro
+
+Knapsack Pro has Queue Mode that will split Ruby & JS tests in a dynamic way across parallel CI nodes to ensure each parallel job takes a similar time. Thanks to that there is no bottleneck in your CI pipelines.
+
+__See introduction how the Knapsack Pro add-on works__
+https://youtu.be/rmXES2N0_QU
+
+You may also find useful article how to run parallel dynos on Heroku CI to complete tests faster
+https://docs.knapsackpro.com/2019/how-to-run-tests-faster-on-heroku-ci-with-parallel-dynos
+
+## Do you know
+
+* Knapsack Pro is risk-free integration! Knapsack Pro runs tests in Fallback Mode if your CI servers can't reach our API for any reason.
+* We don't need access to your repository. Knapsack Pro is just wrapper around test runner like RSpec, Cucumber, Minitest etc.
+* Hundreds of developers use Knapsack Pro every day to run fast CI builds.
+* It works with other programming languages.
diff --git a/bin/print_header.sh b/bin/print_header.sh
deleted file mode 100755
index cca2921..0000000
--- a/bin/print_header.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-echo ==========================================================================================================================
-echo $1
-echo ==========================================================================================================================
diff --git a/debian/changelog b/debian/changelog
index 850f99d..64962c8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ruby-knapsack (4.0.0+git20221031.1.f824140-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Thu, 19 Jan 2023 21:02:40 -0000
+
ruby-knapsack (1.18.0-2) unstable; urgency=medium
* Source only upload for testing migration
diff --git a/knapsack.gemspec b/knapsack.gemspec
index 6f799d5..66bc344 100644
--- a/knapsack.gemspec
+++ b/knapsack.gemspec
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.email = ["arturtrzop@gmail.com"]
spec.summary = %q{Knapsack splits tests across CI nodes and makes sure that tests will run comparable time on each node.}
spec.description = %q{Parallel tests across CI server nodes based on each test file's time execution. It generates a test time execution report and uses it for future test runs.}
- spec.homepage = "https://github.com/ArturT/knapsack"
+ spec.homepage = "https://github.com/KnapsackPro/knapsack"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
@@ -18,17 +18,16 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
- spec.required_ruby_version = '>= 1.9.3'
+ spec.required_ruby_version = '>= 2.2'
spec.add_dependency 'rake', '>= 0'
spec.add_development_dependency 'bundler', '>= 1.6'
- spec.add_development_dependency 'rspec', '~> 3.0', '>= 2.10.0'
- spec.add_development_dependency 'rspec-its', '~> 1.2'
+ spec.add_development_dependency 'rspec', '~> 3.0'
+ spec.add_development_dependency 'rspec-its', '~> 1.3'
spec.add_development_dependency 'cucumber', '>= 0'
spec.add_development_dependency 'spinach', '>= 0.8'
spec.add_development_dependency 'minitest', '>= 5.0.0'
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 0'
spec.add_development_dependency 'pry', '~> 0'
- spec.add_development_dependency 'timecop', '>= 0.1.0'
+ spec.add_development_dependency 'timecop', '>= 0.9.4'
end
diff --git a/lib/knapsack/adapters/minitest_adapter.rb b/lib/knapsack/adapters/minitest_adapter.rb
index 5521d9b..d187659 100644
--- a/lib/knapsack/adapters/minitest_adapter.rb
+++ b/lib/knapsack/adapters/minitest_adapter.rb
@@ -23,20 +23,20 @@ module Knapsack
def bind_time_tracker
::Minitest::Test.send(:include, BindTimeTrackerMinitestPlugin)
- add_post_run_callback do
+ Minitest.after_run do
Knapsack.logger.info(Presenter.global_time)
end
end
def bind_report_generator
- add_post_run_callback do
+ Minitest.after_run do
Knapsack.report.save
Knapsack.logger.info(Presenter.report_details)
end
end
def bind_time_offset_warning
- add_post_run_callback do
+ Minitest.after_run do
Knapsack.logger.log(
Presenter.time_offset_log_level,
Presenter.time_offset_warning
@@ -64,16 +64,6 @@ module Knapsack
# test_path will look like ./test/dir/unit_test.rb
test_path
end
-
- private
-
- def add_post_run_callback(&block)
- if Minitest.respond_to?(:after_run)
- Minitest.after_run { block.call }
- else
- Minitest::Unit.after_tests { block.call }
- end
- end
end
end
end
diff --git a/lib/knapsack/adapters/rspec_adapter.rb b/lib/knapsack/adapters/rspec_adapter.rb
index 5bf3595..e7ec7e0 100644
--- a/lib/knapsack/adapters/rspec_adapter.rb
+++ b/lib/knapsack/adapters/rspec_adapter.rb
@@ -6,18 +6,15 @@ module Knapsack
def bind_time_tracker
::RSpec.configure do |config|
- config.prepend_before(:each) do
- current_example_group =
- if ::RSpec.respond_to?(:current_example)
- ::RSpec.current_example.metadata[:example_group]
- else
- example.metadata
- end
- Knapsack.tracker.test_path = RSpecAdapter.test_path(current_example_group)
+ config.prepend_before(:context) do
Knapsack.tracker.start_timer
end
- config.append_after(:each) do
+ config.prepend_before(:each) do |example|
+ Knapsack.tracker.test_path = RSpecAdapter.test_path(example)
+ end
+
+ config.append_after(:context) do
Knapsack.tracker.stop_timer
end
@@ -47,8 +44,10 @@ module Knapsack
end
end
- def self.test_path(example_group)
- if defined?(Turnip) && Turnip::VERSION.to_i < 2
+ def self.test_path(example)
+ example_group = example.metadata[:example_group]
+
+ if defined?(::Turnip) && Gem::Version.new(::Turnip::VERSION) < Gem::Version.new('2.0.0')
unless example_group[:turnip]
until example_group[:parent_example_group].nil?
example_group = example_group[:parent_example_group]
diff --git a/lib/knapsack/config/env.rb b/lib/knapsack/config/env.rb
index 1349439..1e3fd7b 100644
--- a/lib/knapsack/config/env.rb
+++ b/lib/knapsack/config/env.rb
@@ -7,11 +7,11 @@ module Knapsack
end
def ci_node_total
- ENV['CI_NODE_TOTAL'] || ENV['CIRCLE_NODE_TOTAL'] || ENV['SEMAPHORE_JOB_COUNT'] || ENV['SEMAPHORE_THREAD_COUNT'] || ENV['BUILDKITE_PARALLEL_JOB_COUNT'] || ENV['SNAP_WORKER_TOTAL'] || 1
+ ENV['CI_NODE_TOTAL'] || ENV['CIRCLE_NODE_TOTAL'] || ENV['SEMAPHORE_JOB_COUNT'] || ENV['SEMAPHORE_THREAD_COUNT'] || ENV['BUILDKITE_PARALLEL_JOB_COUNT'] || ENV['SNAP_WORKER_TOTAL'] || ENV['BITBUCKET_PARALLEL_STEP_COUNT'] || 1
end
def ci_node_index
- gitlab_ci_node_index || ENV['CI_NODE_INDEX'] || ENV['CIRCLE_NODE_INDEX'] || semaphore_job_index || semaphore_current_thread || ENV['BUILDKITE_PARALLEL_JOB'] || snap_ci_worker_index || 0
+ gitlab_ci_node_index || ENV['CI_NODE_INDEX'] || ENV['CIRCLE_NODE_INDEX'] || semaphore_job_index || semaphore_current_thread || ENV['BUILDKITE_PARALLEL_JOB'] || snap_ci_worker_index || ENV['BITBUCKET_PARALLEL_STEP'] || 0
end
def test_file_pattern
diff --git a/lib/knapsack/distributors/report_distributor.rb b/lib/knapsack/distributors/report_distributor.rb
index 579851e..c732365 100644
--- a/lib/knapsack/distributors/report_distributor.rb
+++ b/lib/knapsack/distributors/report_distributor.rb
@@ -2,7 +2,7 @@ module Knapsack
module Distributors
class ReportDistributor < BaseDistributor
def sorted_report
- @sorted_report ||= report.sort_by { |test_path, time| time }.reverse
+ @sorted_report ||= report.sort_by { |_test_path, time| -time }
end
def sorted_report_with_existing_tests
@@ -10,7 +10,7 @@ module Knapsack
end
def total_time_execution
- @total_time_execution ||= sorted_report_with_existing_tests.map(&:last).reduce(0, :+).to_f
+ @total_time_execution ||= sorted_report_with_existing_tests.map { |_test_path, time| time }.reduce(0, :+).to_f
end
def node_time_execution
@@ -20,73 +20,52 @@ module Knapsack
private
def post_assign_test_files_to_node
- assign_slow_test_files
- assign_remaining_test_files
+ assign_test_files
sort_assigned_test_files
end
def sort_assigned_test_files
- ci_node_total.times do |index|
- # sort by first key (file name)
- # reverse it and then sort by second key (time) in reverse order
- node_tests[index][:test_files_with_time].sort!.reverse!.sort! do |x, y|
- y[1] <=> x[1]
- end
+ node_tests.map do |node|
+ node[:test_files_with_time]
+ .sort_by! { |file_name, _time| file_name }
+ .reverse!
+ .sort_by! { |_file_name, time| time }
+ .reverse!
end
end
def post_tests_for_node(node_index)
node_test = node_tests[node_index]
return unless node_test
- node_test[:test_files_with_time].map(&:first)
+ node_test[:test_files_with_time].map { |file_name, _time| file_name }
end
def default_node_tests
- @node_tests = []
- ci_node_total.times do |index|
- @node_tests << {
+ @node_tests = Array.new(ci_node_total) do |index|
+ {
node_index: index,
time_left: node_time_execution,
- test_files_with_time: []
+ test_files_with_time: [],
+ weight: 0
}
end
end
- def assign_slow_test_files
- @not_assigned_test_files = []
- node_index = 0
- sorted_report_with_existing_tests.each do |test_file_with_time|
- assign_slow_test_file(node_index, test_file_with_time)
- node_index += 1
- node_index %= ci_node_total
- end
- end
+ def assign_test_files
+ sorted_report_with_existing_tests.map do |test_file_with_time|
+ test_execution_time = test_file_with_time.last
- def assign_slow_test_file(node_index, test_file_with_time)
- time = test_file_with_time[1]
- time_left = node_tests[node_index][:time_left] - time
+ current_lightest_node = node_tests.min_by { |node| node[:weight] }
- if time_left >= 0 or node_tests[node_index][:test_files_with_time].empty?
- node_tests[node_index][:time_left] -= time
- node_tests[node_index][:test_files_with_time] << test_file_with_time
- else
- @not_assigned_test_files << test_file_with_time
- end
- end
+ updated_node_data = {
+ time_left: current_lightest_node[:time_left] - test_execution_time,
+ weight: current_lightest_node[:weight] + test_execution_time,
+ test_files_with_time: current_lightest_node[:test_files_with_time] << test_file_with_time
+ }
- def assign_remaining_test_files
- @not_assigned_test_files.each do |test_file_with_time|
- index = node_with_max_time_left
- time = test_file_with_time[1]
- node_tests[index][:time_left] -= time
- node_tests[index][:test_files_with_time] << test_file_with_time
+ current_lightest_node.merge!(updated_node_data)
end
end
-
- def node_with_max_time_left
- node_test = node_tests.max { |a,b| a[:time_left] <=> b[:time_left] }
- node_test[:node_index]
- end
end
end
end
diff --git a/lib/knapsack/presenter.rb b/lib/knapsack/presenter.rb
index c62f8ab..0fefe9f 100644
--- a/lib/knapsack/presenter.rb
+++ b/lib/knapsack/presenter.rb
@@ -51,10 +51,14 @@ module Knapsack
}
if Knapsack.tracker.time_exceeded?
str << %{
-Tests on this CI node took more than max allowed node time execution.
+Test on this CI node ran for longer than the max allowed node time execution.
Please regenerate your knapsack report.
-If that didn't help then split your heavy test file
-or bump time_offset_in_seconds setting.}
+
+If that doesn't help, you can split your slowest test files into smaller files, or bump up the time_offset_in_seconds setting.
+
+You can also allow the knapsack_pro gem to automatically divide your slow test files across parallel CI nodes.
+https://knapsackpro.com/faq/question/how-to-auto-split-test-files-by-test-cases-on-parallel-jobs-ci-nodes?utm_source=knapsack_gem&utm_medium=knapsack_gem_output&utm_campaign=knapsack_gem_time_offset_warning
+}
else
str << %{
Global time execution for this CI node is fine.
@@ -63,9 +67,8 @@ Happy testing!}
str << "\n\nNeed explanation? See FAQ:"
str << "\nhttps://docs.knapsackpro.com/ruby/knapsack#faq"
str << "\n=================================================\n"
- str << %{See how to split tests in a dynamic way using Queue Mode to ensure all parallel nodes
-finish work at a similar time even when your CI or random test execution is a bottleneck:
-https://youtu.be/hUEB1XDKEFY
+ str << %{Read up on the benefits of a dynamic test split with Knapsack Pro Queue Mode:
+https://docs.knapsackpro.com/2020/how-to-speed-up-ruby-and-javascript-tests-with-ci-parallelisation
Sign up for Knapsack Pro here:
https://knapsackpro.com}
diff --git a/lib/knapsack/tracker.rb b/lib/knapsack/tracker.rb
index a973238..8514c41 100644
--- a/lib/knapsack/tracker.rb
+++ b/lib/knapsack/tracker.rb
@@ -23,15 +23,19 @@ module Knapsack
end
def stop_timer
- @execution_time = now_without_mock_time.to_f - @start_time
- update_global_time
- update_test_file_time
- @execution_time
+ execution_time = now_without_mock_time.to_f - @start_time
+
+ if test_path
+ update_global_time(execution_time)
+ update_test_file_time(execution_time)
+ @test_path = nil
+ end
+
+ execution_time
end
def test_path
- raise("test_path needs to be set by Knapsack Adapter's bind method") unless @test_path
- @test_path.sub(/^\.\//, '')
+ @test_path.sub(/^\.\//, '') if @test_path
end
def time_exceeded?
@@ -62,13 +66,13 @@ module Knapsack
@test_path = nil
end
- def update_global_time
- @global_time += @execution_time
+ def update_global_time(execution_time)
+ @global_time += execution_time
end
- def update_test_file_time
+ def update_test_file_time(execution_time)
@test_files_with_time[test_path] ||= 0
- @test_files_with_time[test_path] += @execution_time
+ @test_files_with_time[test_path] += execution_time
end
def report_distributor
@@ -81,11 +85,7 @@ module Knapsack
end
def now_without_mock_time
- if defined?(Timecop)
- Time.now_without_mock_time
- else
- Time.raw_now
- end
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
end
end
diff --git a/lib/knapsack/version.rb b/lib/knapsack/version.rb
index 4e0d8aa..0b2ea0f 100644
--- a/lib/knapsack/version.rb
+++ b/lib/knapsack/version.rb
@@ -1,3 +1,3 @@
module Knapsack
- VERSION = '1.18.0'
+ VERSION = '4.0.0'
end
diff --git a/spec/knapsack/adapters/rspec_adapter_spec.rb b/spec/knapsack/adapters/rspec_adapter_spec.rb
index 8ead20e..91f3823 100644
--- a/spec/knapsack/adapters/rspec_adapter_spec.rb
+++ b/spec/knapsack/adapters/rspec_adapter_spec.rb
@@ -16,27 +16,21 @@ describe Knapsack::Adapters::RSpecAdapter do
let(:tracker) { instance_double(Knapsack::Tracker) }
let(:test_path) { 'spec/a_spec.rb' }
let(:global_time) { 'Global time: 01m 05s' }
- let(:example_group) { double }
- let(:current_example) do
- OpenStruct.new(metadata: {
- example_group: example_group
- })
- end
+ let(:current_example) { double }
it do
- expect(config).to receive(:prepend_before).with(:each).and_yield
- expect(config).to receive(:append_after).with(:each).and_yield
+ expect(config).to receive(:prepend_before).with(:context).and_yield
+ expect(config).to receive(:prepend_before).with(:each).and_yield(current_example)
+ expect(config).to receive(:append_after).with(:context).and_yield
expect(config).to receive(:after).with(:suite).and_yield
expect(::RSpec).to receive(:configure).and_yield(config)
- expect(::RSpec).to receive(:current_example).twice.and_return(current_example)
- expect(described_class).to receive(:test_path).with(example_group).and_return(test_path)
+ expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
allow(Knapsack).to receive(:tracker).and_return(tracker)
- expect(tracker).to receive(:test_path=).with(test_path)
- expect(tracker).to receive(:start_timer)
-
- expect(tracker).to receive(:stop_timer)
+ expect(tracker).to receive(:start_timer).ordered
+ expect(tracker).to receive(:test_path=).with(test_path).ordered
+ expect(tracker).to receive(:stop_timer).ordered
expect(Knapsack::Presenter).to receive(:global_time).and_return(global_time)
expect(logger).to receive(:info).with(global_time)
@@ -81,7 +75,7 @@ describe Knapsack::Adapters::RSpecAdapter do
end
describe '.test_path' do
- let(:current_example_metadata) do
+ let(:example_group) do
{
file_path: '1_shared_example.rb',
parent_example_group: {
@@ -92,14 +86,19 @@ describe Knapsack::Adapters::RSpecAdapter do
}
}
end
+ let(:current_example) do
+ OpenStruct.new(metadata: {
+ example_group: example_group
+ })
+ end
- subject { described_class.test_path(current_example_metadata) }
+ subject { described_class.test_path(current_example) }
it { should eql 'a_spec.rb' }
context 'with turnip features' do
describe 'when the turnip version is less than 2' do
- let(:current_example_metadata) do
+ let(:example_group) do
{
file_path: "./spec/features/logging_in.feature",
turnip: true,
@@ -115,7 +114,7 @@ describe Knapsack::Adapters::RSpecAdapter do
end
describe 'when turnip is version 2 or greater' do
- let(:current_example_metadata) do
+ let(:example_group) do
{
file_path: "gems/turnip-2.0.0/lib/turnip/rspec.rb",
turnip: true,
diff --git a/spec/knapsack/config/env_spec.rb b/spec/knapsack/config/env_spec.rb
index 8e2f344..669f57b 100644
--- a/spec/knapsack/config/env_spec.rb
+++ b/spec/knapsack/config/env_spec.rb
@@ -46,6 +46,11 @@ describe Knapsack::Config::Env do
before { stub_const("ENV", { 'SNAP_WORKER_TOTAL' => 6 }) }
it { should eql 6 }
end
+
+ context 'when BITBUCKET_PARALLEL_STEP_COUNT has value' do
+ before { stub_const("ENV", { 'BITBUCKET_PARALLEL_STEP_COUNT' => 8 }) }
+ it { should eql 8 }
+ end
end
context "when ENV doesn't exist" do
@@ -91,6 +96,11 @@ describe Knapsack::Config::Env do
before { stub_const("ENV", { 'SNAP_WORKER_INDEX' => 4 }) }
it { should eql 3 }
end
+
+ context 'when BITBUCKET_PARALLEL_STEP has value' do
+ before { stub_const("ENV", { 'BITBUCKET_PARALLEL_STEP' => 7 }) }
+ it { should eql 7 }
+ end
end
context "when ENV doesn't exist" do
diff --git a/spec/knapsack/distributors/report_distributor_spec.rb b/spec/knapsack/distributors/report_distributor_spec.rb
index 117f756..1166386 100644
--- a/spec/knapsack/distributors/report_distributor_spec.rb
+++ b/spec/knapsack/distributors/report_distributor_spec.rb
@@ -118,7 +118,7 @@ describe Knapsack::Distributors::ReportDistributor do
'c_spec.rb' => 2.0,
'd_spec.rb' => 2.5,
'a_spec.rb' => 1.0,
- 'b_spec.rb' => 1.5,
+ 'b_spec.rb' => 1.5
}
end
let(:custom_args) { { ci_node_total: 3 } }
@@ -134,6 +134,7 @@ describe Knapsack::Distributors::ReportDistributor do
expect(distributor.node_tests[0]).to eql({
:node_index => 0,
:time_left => -0.5,
+ :weight => 9.0,
:test_files_with_time => [
["g_spec.rb", 9.0]
]
@@ -143,12 +144,12 @@ describe Knapsack::Distributors::ReportDistributor do
it do
expect(distributor.node_tests[1]).to eql({
:node_index => 1,
- :time_left => 0.0,
+ :time_left => 0.5,
+ :weight => 8.0,
:test_files_with_time => [
["f_spec.rb", 3.5],
["d_spec.rb", 2.5],
- ["b_spec.rb", 1.5],
- ["a_spec.rb", 1.0]
+ ["c_spec.rb", 2.0]
]
})
end
@@ -156,11 +157,13 @@ describe Knapsack::Distributors::ReportDistributor do
it do
expect(distributor.node_tests[2]).to eql({
:node_index => 2,
- :time_left => 0.5,
+ :time_left => 0.0,
+ :weight => 8.5,
:test_files_with_time => [
- ["i_spec.rb", 3.0],
["h_spec.rb", 3.0],
- ["c_spec.rb", 2.0]
+ ["i_spec.rb", 3.0],
+ ["b_spec.rb", 1.5],
+ ["a_spec.rb", 1.0]
]
})
end
@@ -170,10 +173,9 @@ describe Knapsack::Distributors::ReportDistributor do
context 'when node exists' do
it do
expect(distributor.tests_for_node(1)).to eql([
- 'f_spec.rb',
- 'd_spec.rb',
- 'b_spec.rb',
- 'a_spec.rb'
+ "f_spec.rb",
+ "d_spec.rb",
+ "c_spec.rb"
])
end
end
@@ -183,4 +185,78 @@ describe Knapsack::Distributors::ReportDistributor do
end
end
end
+
+ describe 'algorithmic efficiency' do
+ subject(:node_weights) do
+ distro = distributor
+ distro.assign_test_files_to_node
+ distro.node_tests.map { |node| node[:weight] }
+ end
+
+ before do
+ allow(distributor).to receive(:all_tests).and_return(report.keys)
+ end
+
+ let(:custom_args) { { ci_node_total: 3 } }
+
+ context 'with the most simple example' do
+ let(:report) do
+ {
+ 'a_spec.rb' => 1.0,
+ 'b_spec.rb' => 1.0,
+ 'c_spec.rb' => 1.0,
+ 'd_spec.rb' => 1.0,
+ 'e_spec.rb' => 1.0,
+ 'f_spec.rb' => 1.0,
+ 'g_spec.rb' => 1.0,
+ 'h_spec.rb' => 1.0,
+ 'i_spec.rb' => 1.0
+ }
+ end
+
+ it 'assigns all nodes equally' do
+ expect(node_weights.uniq).to contain_exactly 3.0
+ end
+ end
+
+ context 'with a medium difficulty example' do
+ let(:report) do
+ {
+ 'a_spec.rb' => 1.0,
+ 'b_spec.rb' => 2.0,
+ 'c_spec.rb' => 3.0,
+ 'd_spec.rb' => 1.0,
+ 'e_spec.rb' => 2.0,
+ 'f_spec.rb' => 3.0,
+ 'g_spec.rb' => 1.0,
+ 'h_spec.rb' => 2.0,
+ 'i_spec.rb' => 3.0
+ }
+ end
+
+ it 'assigns all nodes equally' do
+ expect(node_weights.uniq).to contain_exactly 6.0
+ end
+ end
+
+ context 'with a difficult example' do
+ let(:report) do
+ {
+ 'a_spec.rb' => 2.0,
+ 'b_spec.rb' => 2.0,
+ 'c_spec.rb' => 3.0,
+ 'd_spec.rb' => 1.0,
+ 'e_spec.rb' => 1.0,
+ 'f_spec.rb' => 1.0,
+ 'g_spec.rb' => 9.0,
+ 'h_spec.rb' => 1.0,
+ 'i_spec.rb' => 10.0
+ }
+ end
+
+ it 'assigns all nodes equally' do
+ expect(node_weights.uniq).to contain_exactly 10.0
+ end
+ end
+ end
end
diff --git a/spec/knapsack/tracker_spec.rb b/spec/knapsack/tracker_spec.rb
index d9036f1..a3a34dd 100644
--- a/spec/knapsack/tracker_spec.rb
+++ b/spec/knapsack/tracker_spec.rb
@@ -48,7 +48,7 @@ describe Knapsack::Tracker do
context 'when test_path not set' do
it do
- expect { subject }.to raise_error("test_path needs to be set by Knapsack Adapter's bind method")
+ expect(subject).to be_nil
end
end
@@ -133,6 +133,9 @@ describe Knapsack::Tracker do
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
it { expect(tracker.test_files_with_time['a_spec.rb']).to be_within(delta).of(0.1) }
it { expect(tracker.test_files_with_time['b_spec.rb']).to be_within(delta).of(0.2) }
+ it 'resets test_path after time is measured' do
+ expect(tracker.test_path).to be_nil
+ end
end
context "with Timecop - Timecop shouldn't have impact on measured test time" do
@@ -157,6 +160,9 @@ describe Knapsack::Tracker do
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
it { expect(tracker.test_files_with_time['a_spec.rb']).to be_within(delta).of(0) }
it { expect(tracker.test_files_with_time['b_spec.rb']).to be_within(delta).of(0) }
+ it 'resets test_path after time is measured' do
+ expect(tracker.test_path).to be_nil
+ end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index cb326c2..7d05254 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -4,9 +4,6 @@ require 'spinach'
require 'timecop'
Timecop.safe_mode = true
-require 'codeclimate-test-reporter'
-CodeClimate::TestReporter.start
-
require 'knapsack'
Dir["#{Knapsack.root}/spec/support/**/*.rb"].each { |f| require f }
diff --git a/test_examples/fast/shared_examples_test.rb b/test_examples/fast/shared_examples_test.rb
index 60010ca..340f7d5 100644
--- a/test_examples/fast/shared_examples_test.rb
+++ b/test_examples/fast/shared_examples_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
class Minitest::SharedExamples < Module
- include Minitest::Spec::DSL if RUBY_VERSION != "1.9.3"
+ include Minitest::Spec::DSL
end
SharedExampleSpec = Minitest::SharedExamples.new do
diff --git a/test_examples/fast/spec_test.rb b/test_examples/fast/spec_test.rb
index 9951275..71aa6e5 100644
--- a/test_examples/fast/spec_test.rb
+++ b/test_examples/fast/spec_test.rb
@@ -16,10 +16,22 @@ describe FakeCalculator do
end
it '#add' do
- @calc.add(2, 3).must_equal 5
+ result = @calc.add(2, 3)
+
+ if self.respond_to?(:_)
+ _(result).must_equal 5
+ else
+ result.must_equal 5
+ end
end
it '#mal' do
- @calc.mal(2, 3).must_equal 6
+ result = @calc.mal(2, 3)
+
+ if self.respond_to?(:_)
+ _(result).must_equal 6
+ else
+ result.must_equal 6
+ end
end
end
diff --git a/test_examples/test_helper.rb b/test_examples/test_helper.rb
index d1e8250..09256b8 100644
--- a/test_examples/test_helper.rb
+++ b/test_examples/test_helper.rb
@@ -2,15 +2,6 @@ require 'minitest/autorun'
require 'knapsack'
-if RUBY_VERSION == "1.9.3"
- unless defined? Minitest
- Minitest = MiniTest
- end
- unless defined? Minitest::Test
- Minitest::Test = MiniTest::Unit::TestCase
- end
-end
-
Knapsack.tracker.config({
enable_time_offset_warning: true,
time_offset_in_seconds: 3
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/logos/knapsack-@2.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/logos/knapsack-big.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/logos/knapsack-logo-@2.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/logos/knapsack-logo-big.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/logos/knapsack-logo.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/logos/knapsack.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/with_knapsack.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/docs/images/without_knapsack.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/adapters/base_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/adapters/cucumber_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/adapters/minitest_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/adapters/rspec_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/adapters/spinach_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/allocator.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/allocator_builder.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/config/env.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/config/tracker.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/distributors/base_distributor.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/distributors/leftover_distributor.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/distributors/report_distributor.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/extensions/time.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/logger.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/presenter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/report.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/runners/cucumber_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/runners/minitest_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/runners/rspec_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/runners/spinach_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/task_loader.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/tracker.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/knapsack/version.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/tasks/knapsack_cucumber.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/tasks/knapsack_minitest.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/tasks/knapsack_rspec.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/lib/tasks/knapsack_spinach.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_engine_examples/1_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/1_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/2_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/3_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/4_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/5_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/6_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/fast/use_shared_example_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/leftover/1_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/leftover/a_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/slow/a_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/slow/b_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/slow/c_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/spec_helper.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spec_examples/support/shared_examples/common_example.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spinach_examples/scenario1.feature -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spinach_examples/scenario2.feature -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spinach_examples/steps/test_how_spinach_works_for_first_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spinach_examples/steps/test_how_spinach_works_for_second_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/spinach_examples/support/env.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/test_examples/fast/shared_examples_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/test_examples/fast/spec_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/test_examples/fast/unit_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/test_examples/slow/slow_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/test_examples/test_helper.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/knapsack-4.0.0.gemspec -rwxr-xr-x root/root /usr/share/rubygems-integration/all/gems/knapsack-4.0.0/bin/knapsack
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/logos/knapsack-@2.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/logos/knapsack-big.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/logos/knapsack-logo-@2.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/logos/knapsack-logo-big.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/logos/knapsack-logo.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/logos/knapsack.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/with_knapsack.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/docs/images/without_knapsack.png -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/adapters/base_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/adapters/cucumber_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/adapters/minitest_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/adapters/rspec_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/adapters/spinach_adapter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/allocator.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/allocator_builder.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/config/env.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/config/tracker.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/distributors/base_distributor.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/distributors/leftover_distributor.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/distributors/report_distributor.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/extensions/time.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/logger.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/presenter.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/report.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/runners/cucumber_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/runners/minitest_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/runners/rspec_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/runners/spinach_runner.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/task_loader.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/tracker.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/knapsack/version.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/tasks/knapsack_cucumber.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/tasks/knapsack_minitest.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/tasks/knapsack_rspec.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/lib/tasks/knapsack_spinach.rake -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_engine_examples/1_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/1_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/2_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/3_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/4_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/5_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/6_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/fast/use_shared_example_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/leftover/1_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/leftover/a_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/slow/a_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/slow/b_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/slow/c_spec.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/spec_helper.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spec_examples/support/shared_examples/common_example.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spinach_examples/scenario1.feature -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spinach_examples/scenario2.feature -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spinach_examples/steps/test_how_spinach_works_for_first_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spinach_examples/steps/test_how_spinach_works_for_second_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/spinach_examples/support/env.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/test_examples/fast/shared_examples_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/test_examples/fast/spec_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/test_examples/fast/unit_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/test_examples/slow/slow_test.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/test_examples/test_helper.rb -rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/knapsack-1.18.0.gemspec -rwxr-xr-x root/root /usr/bin/print_header.sh -rwxr-xr-x root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/bin/knapsack -rwxr-xr-x root/root /usr/share/rubygems-integration/all/gems/knapsack-1.18.0/bin/print_header.sh
No differences were encountered in the control files