Class: TLDR
- Inherits:
-
Object
- Object
- TLDR
- Includes:
- Assertions, Hooks, Skippable
- Defined in:
- lib/tldr/assertions/minitest_compatibility.rb,
lib/tldr.rb,
lib/tldr/rake.rb,
lib/tldr/error.rb,
lib/tldr/hooks.rb,
lib/tldr/runner.rb,
lib/tldr/planner.rb,
lib/tldr/version.rb,
lib/tldr/watcher.rb,
lib/tldr/executor.rb,
lib/tldr/path_util.rb,
lib/tldr/skippable.rb,
lib/tldr/assertions.rb,
lib/tldr/class_util.rb,
lib/tldr/value/plan.rb,
lib/tldr/value/test.rb,
lib/tldr/argv_parser.rb,
lib/tldr/strategizer.rb,
lib/tldr/value/config.rb,
lib/tldr/reporters/base.rb,
lib/tldr/value/location.rb,
lib/tldr/value/wip_test.rb,
lib/tldr/backtrace_filter.rb,
lib/tldr/value/test_group.rb,
lib/tldr/parallel_controls.rb,
lib/tldr/reporters/default.rb,
lib/tldr/value/test_result.rb,
lib/tldr/sorbet_compatibility.rb
Overview
These methods are provided only for drop-in compatibility with Minitest:
require "tldr/assertions/minitest"
Will load these methods for use in your tests
While all the methods in this file were written for TLDR, they were designed to maximize compatibility with minitest’s assertions API and messages here:
https://github.com/minitest/minitest/blob/master/lib/minitest/assertions.rb
As a result, many implementations are extremely similar to those found in minitest. Any such implementations are Copyright © Ryan Davis, seattle.rb and distributed under the MIT License
Defined Under Namespace
Modules: Assertions, ClassUtil, Hooks, PathUtil, Reporters, Run, Skippable Classes: ArgvParser, BacktraceFilter, Config, Error, Executor, Failure, Location, Plan, Planner, Runner, Skip, SorbetCompatibility, Strategizer, Task, Test, TestGroup, TestResult, WIPTest, Watcher
Constant Summary collapse
- VERSION =
"0.10.0"
- CONFLAGS =
{ seed: "--seed", no_helper: "--no-helper", verbose: "--verbose", print_interrupted_test_backtraces: "--print-interrupted-test-backtraces", reporter: "--reporter", helper_paths: "--helper", load_paths: "--load-path", parallel: "--[no-]parallel", names: "--name", fail_fast: "--fail-fast", no_emoji: "--no-emoji", prepend_paths: "--prepend", no_prepend: "--no-prepend", exclude_paths: "--exclude-path", exclude_names: "--exclude-name", base_path: "--base-path", no_dotfile: "--no-dotfile", warnings: "--[no-]warnings", watch: "--watch", yes_i_know: "--yes-i-know", i_am_being_watched: "--i-am-being-watched", paths: nil }.freeze
- PATH_FLAGS =
[:paths, :helper_paths, :load_paths, :prepend_paths, :exclude_paths].freeze
- MOST_RECENTLY_MODIFIED_TAG =
"MOST_RECENTLY_MODIFIED".freeze
- CONFIG_ATTRIBUTES =
[ :paths, :seed, :no_helper, :verbose, :print_interrupted_test_backtraces, :reporter, :helper_paths, :load_paths, :parallel, :names, :fail_fast, :no_emoji, :prepend_paths, :no_prepend, :exclude_paths, :exclude_names, :base_path, :no_dotfile, :warnings, :watch, :yes_i_know, :i_am_being_watched, # Internal properties :config_intended_for_merge_only, :seed_set_intentionally, :cli_defaults ].freeze
- GROUPED_TESTS =
If it’s not safe to run a set of tests in parallel, you can force them to run in a group together (in a single worker) with ‘run_these_together!` in your test.
This method takes an array of tuples, where the first element is the class (or its name as a string, if the class is not yet defined in the current file) and the second element is the method name. If the second element is nil, then all the tests on the class will be run together.
Examples:
- `run_these_together!` will run all the tests defined on the current class to be run in a group - `run_these_together!([[ClassA, nil], ["ClassB", :test_1], [ClassB, :test_2]])` will run all the tests defined on ClassA, and test_1 and test_2 from ClassB
Concurrent::Array.new
- THREAD_UNSAFE_TESTS =
This is a similar API to run_these_together! but its effect is more drastic Rather than running the provided (class, method) tuples in a group within a thread as part of a parallel run, it will reserve all tests specified by all calls to ‘dont_run_these_in_parallel!` to be run after all parallel tests have finished.
This has an important implication! If your test suite is over TLDR’s time limit, it means that these tests will never be run outside of CI unless you run them manually.
Like ‘run_these_together!`, `dont_run_these_in_parallel!` takes an array of tuples, where the first element is the class (or its fully-qualified name as a string) and the second element is `nil` (matching all the class’s test methods) or else one of the methods on the class.
Examples:
- `dont_run_these_in_parallel!` will run all the tests defined on the current class after all parallel tests have finished - `dont_run_these_in_parallel!([[ClassA, nil], ["ClassB", :test_1], [ClassB, :test_2]])` will run all the tests defined on ClassA, and test_1 and test_2 from ClassB
Concurrent::Array.new
Class Method Summary collapse
- .dont_run_these_in_parallel!(klass_method_tuples = [[self, nil]]) ⇒ Object
- .filter_backtrace(backtrace) ⇒ Object
- .run_these_together!(klass_method_tuples = [[self, nil]]) ⇒ Object
Methods included from Hooks
Methods included from Skippable
Methods included from Assertions
#assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_include?, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_pattern, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_silent, #assert_throws, capture_io, diff, h, msg, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_include?, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_pattern, #refute_predicate, #refute_respond_to, #refute_same
Class Method Details
.dont_run_these_in_parallel!(klass_method_tuples = [[self, nil]]) ⇒ Object
44 45 46 |
# File 'lib/tldr/parallel_controls.rb', line 44 def self.dont_run_these_in_parallel! klass_method_tuples = [[self, nil]] THREAD_UNSAFE_TESTS << TestGroup.new(klass_method_tuples) end |
.filter_backtrace(backtrace) ⇒ Object
37 38 39 |
# File 'lib/tldr/backtrace_filter.rb', line 37 def self.filter_backtrace backtrace BacktraceFilter.new.filter(backtrace) end |
.run_these_together!(klass_method_tuples = [[self, nil]]) ⇒ Object
18 19 20 |
# File 'lib/tldr/parallel_controls.rb', line 18 def self.run_these_together! klass_method_tuples = [[self, nil]] GROUPED_TESTS << TestGroup.new(klass_method_tuples) end |