Class: RSpecTracer::Cache
- Inherits:
-
Object
- Object
- RSpecTracer::Cache
- Defined in:
- lib/rspec_tracer/cache.rb
Instance Attribute Summary collapse
-
#all_examples ⇒ Object
readonly
Returns the value of attribute all_examples.
-
#all_files ⇒ Object
readonly
Returns the value of attribute all_files.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#duplicate_examples ⇒ Object
readonly
Returns the value of attribute duplicate_examples.
-
#examples_coverage ⇒ Object
readonly
Returns the value of attribute examples_coverage.
-
#failed_examples ⇒ Object
readonly
Returns the value of attribute failed_examples.
-
#flaky_examples ⇒ Object
readonly
Returns the value of attribute flaky_examples.
-
#interrupted_examples ⇒ Object
readonly
Returns the value of attribute interrupted_examples.
-
#pending_examples ⇒ Object
readonly
Returns the value of attribute pending_examples.
-
#run_id ⇒ Object
readonly
Returns the value of attribute run_id.
-
#skipped_examples ⇒ Object
readonly
Returns the value of attribute skipped_examples.
Instance Method Summary collapse
- #cached_examples_coverage ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #load_cache_for_run ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rspec_tracer/cache.rb', line 9 def initialize @cached = false @all_examples = {} @duplicate_examples = {} @interrupted_examples = Set.new @flaky_examples = Set.new @failed_examples = Set.new @pending_examples = Set.new @all_files = {} @dependency = Hash.new { |hash, key| hash[key] = Set.new } end |
Instance Attribute Details
#all_examples ⇒ Object (readonly)
Returns the value of attribute all_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def all_examples @all_examples end |
#all_files ⇒ Object (readonly)
Returns the value of attribute all_files.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def all_files @all_files end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def dependency @dependency end |
#duplicate_examples ⇒ Object (readonly)
Returns the value of attribute duplicate_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def duplicate_examples @duplicate_examples end |
#examples_coverage ⇒ Object (readonly)
Returns the value of attribute examples_coverage.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def examples_coverage @examples_coverage end |
#failed_examples ⇒ Object (readonly)
Returns the value of attribute failed_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def failed_examples @failed_examples end |
#flaky_examples ⇒ Object (readonly)
Returns the value of attribute flaky_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def flaky_examples @flaky_examples end |
#interrupted_examples ⇒ Object (readonly)
Returns the value of attribute interrupted_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def interrupted_examples @interrupted_examples end |
#pending_examples ⇒ Object (readonly)
Returns the value of attribute pending_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def pending_examples @pending_examples end |
#run_id ⇒ Object (readonly)
Returns the value of attribute run_id.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def run_id @run_id end |
#skipped_examples ⇒ Object (readonly)
Returns the value of attribute skipped_examples.
5 6 7 |
# File 'lib/rspec_tracer/cache.rb', line 5 def skipped_examples @skipped_examples end |
Instance Method Details
#cached_examples_coverage ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rspec_tracer/cache.rb', line 52 def cached_examples_coverage return @examples_coverage if defined?(@examples_coverage) cache_path = RSpecTracer.cache_path cache_path = File.dirname(cache_path) if RSpecTracer.parallel_tests? run_id = last_run_id(cache_path) return @examples_coverage = {} if run_id.nil? starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) cache_dir = File.join(cache_path, run_id) coverage = load_examples_coverage_cache(cache_dir) ending = Process.clock_gettime(Process::CLOCK_MONOTONIC) elapsed = RSpecTracer::TimeFormatter.format_time(ending - starting) puts "RSpec tracer loaded cached examples coverage (took #{elapsed})" if RSpecTracer.verbose? coverage end |
#load_cache_for_run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rspec_tracer/cache.rb', line 22 def load_cache_for_run return if @cached cache_path = RSpecTracer.cache_path cache_path = File.dirname(cache_path) if RSpecTracer.parallel_tests? run_id = last_run_id(cache_path) return if run_id.nil? starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) cache_dir = File.join(cache_path, run_id) load_all_examples_cache(cache_dir) load_duplicate_examples_cache(cache_dir) load_interrupted_examples_cache(cache_dir) load_flaky_examples_cache(cache_dir) load_failed_examples_cache(cache_dir) load_pending_examples_cache(cache_dir) load_all_files_cache(cache_dir) load_dependency_cache(cache_dir) ending = Process.clock_gettime(Process::CLOCK_MONOTONIC) @cached = true elapsed = RSpecTracer::TimeFormatter.format_time(ending - starting) puts "RSpec tracer loaded cache from #{cache_dir} (took #{elapsed})" end |