diff_test 0.8.6 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d912f83be5f069f6801db49f64088b2300053e75927b9b15994d3a69630954ff
4
- data.tar.gz: 1b7f27298ad240ad3d4f2f9f75257de1ebadc47ffdd7da7656f72318524bd36f
3
+ metadata.gz: 30a81175a332e93a6bb3791a2457c3f8afd04217a8f48ccb1d1abf48306407b7
4
+ data.tar.gz: '0891219e6104458312cdc2fbf164218318271349fcc8e1c2b42ade2b55546451'
5
5
  SHA512:
6
- metadata.gz: ac0dba39aa22af19f73911ae8e70d2ba0acb17484f720d39f8f18d355ccb62cd50b4b3d077cb478119f1464eea0a2bdb69c87135d63f76dc02900b61e33ac74d
7
- data.tar.gz: c50115b9407f7904675e987e930485932cc72a9da2a148361f9ae05e7c996c35171606e98b338ff4533799edfa083282b3634f8455dd9aa6246de24720e4424c
6
+ metadata.gz: 3bdc4073b05ac2260f8875e3fb309d27d306507598d1f4d85f5941515ad5878fd2101cfe166fa2ffd3579794180de1bfe5e63b080cc7edf0592202788a0801fe
7
+ data.tar.gz: aab168ef2a5be65d5f7fb551cc0a7f1e9ac3513539d8b6b6f78e82dbfe0c87d9544bb1a2687a741f459345fff9751d2ae618de1cf58c4cac0904b53346470701
data/README.md CHANGED
@@ -253,3 +253,6 @@ test/services/zoom_webhook_event_processor_test.rb
253
253
 
254
254
  overhead of const TracePoint and file path prefix native
255
255
  method_added/const_added
256
+
257
+
258
+ # WRITE test for it setting time from previous successful run
@@ -55,7 +55,7 @@ module DiffTest
55
55
  test_name = self.name
56
56
 
57
57
  DiffTest::TestExecution.current = execution = DiffTest::TestExecution.new(test_file_path:, test_name:)
58
- should_run = DiffTest::ShouldRunDecider.should_run?(execution.id, system_test: true)
58
+ should_run = execution.should_run?
59
59
  DiffTest::TestSuiteExecution.current.ensure_application_eager_loaded! if should_run
60
60
  rescue => e
61
61
  DiffTest.error("An error ocurred while trying to create a test execution. Please report this issue.\nException: #{e}")
@@ -67,11 +67,10 @@ module DiffTest
67
67
  super
68
68
  else
69
69
  # Skip raises an exception too, which is handled by `capture_exception`
70
- time_it do
71
- capture_exceptions do
72
- skip("Impacted files have not changed. Skipping...")
73
- end
70
+ capture_exceptions do
71
+ skip("Impacted files have not changed. Skipping...")
74
72
  end
73
+ self.time = execution.previous_runtime_s
75
74
  ::Minitest::Result.from(self)
76
75
  end
77
76
  ensure
@@ -8,9 +8,10 @@ module DiffTest
8
8
  end
9
9
 
10
10
  def should_run?(test_id, system_test:)
11
- return true unless @test_executions_by_test
11
+ return { should_run: true } unless @test_executions_by_test
12
12
 
13
13
  previous_test_executions = @test_executions_by_test[test_id] || []
14
+ previous_runtime_ms = nil
14
15
 
15
16
  # If there are any previous test executions run whose impacted files are the same as now
16
17
  # Assume its safe to skip
@@ -23,6 +24,8 @@ module DiffTest
23
24
  DiffTest::FileHashComputer.compute_relative(impacted_file_path) == file_hash
24
25
  end
25
26
  next false unless hashes_match
27
+
28
+ previous_runtime_ms = previous_test_execution['runtime_ms']
26
29
  next true unless system_test
27
30
 
28
31
  test_suite_execution = @test_suite_executions_by_id[previous_test_execution['test_suite_execution_id'].to_s]
@@ -32,8 +35,13 @@ module DiffTest
32
35
  false
33
36
  end
34
37
 
35
- return true if ENV['DIFF_TEST_ALWAYS_RUN'] == '1'
36
- !has_previous_execution_with_no_impacted_changes
38
+ return { should_run: true } if ENV['DIFF_TEST_ALWAYS_RUN'] == '1'
39
+
40
+ should_run = !has_previous_execution_with_no_impacted_changes
41
+ {
42
+ should_run:,
43
+ previous_runtime_ms:,
44
+ }
37
45
  end
38
46
 
39
47
  def self.current
@@ -13,9 +13,16 @@ module DiffTest
13
13
  self.class.set(id, self)
14
14
  end
15
15
 
16
+ def should_run_decider_result
17
+ @should_run_decider_result ||= DiffTest::ShouldRunDecider.should_run?(id, system_test: system_test?)
18
+ end
19
+
16
20
  def should_run?
17
- return @should_run unless @should_run.nil?
18
- @should_run = DiffTest::ShouldRunDecider.should_run?(id, system_test: system_test?)
21
+ should_run_decider_result[:should_run]
22
+ end
23
+
24
+ def previous_runtime_s
25
+ (should_run_decider_result[:previous_runtime_ms] / 1000.0) if should_run_decider_result[:previous_runtime_ms]
19
26
  end
20
27
 
21
28
  def save_payload
@@ -23,7 +30,7 @@ module DiffTest
23
30
  test: id,
24
31
  result: @result,
25
32
  runtime_ms: runtime_ms,
26
- impacted_files: (@impacted_file_tracker.save_payload if passed?),
33
+ impacted_files: (@impacted_file_tracker.save_payload if successful?),
27
34
  }.compact
28
35
  end
29
36
 
@@ -66,6 +73,14 @@ module DiffTest
66
73
  @result == :passed
67
74
  end
68
75
 
76
+ def skipped?
77
+ @result == :skipped
78
+ end
79
+
80
+ def successful?
81
+ passed? || skipped?
82
+ end
83
+
69
84
  def runtime_ms
70
85
  return 0 if @stopped_at.nil? || @started_at.nil?
71
86
  (@stopped_at - @started_at) * 1000
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DiffTest
4
- VERSION = "0.8.6"
4
+ VERSION = "0.8.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diff_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owais
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-20 00:00:00.000000000 Z
11
+ date: 2025-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty