diff_test 0.8.5 → 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 +4 -4
- data/README.md +7 -0
- data/lib/diff_test/api_client.rb +30 -5
- data/lib/diff_test/integrations/minitest/lifecycle.rb +4 -5
- data/lib/diff_test/should_run_decider.rb +11 -3
- data/lib/diff_test/test_execution.rb +18 -3
- data/lib/diff_test/trackers/ruby_file.rb +2 -1
- data/lib/diff_test/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30a81175a332e93a6bb3791a2457c3f8afd04217a8f48ccb1d1abf48306407b7
|
4
|
+
data.tar.gz: '0891219e6104458312cdc2fbf164218318271349fcc8e1c2b42ade2b55546451'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bdc4073b05ac2260f8875e3fb309d27d306507598d1f4d85f5941515ad5878fd2101cfe166fa2ffd3579794180de1bfe5e63b080cc7edf0592202788a0801fe
|
7
|
+
data.tar.gz: aab168ef2a5be65d5f7fb551cc0a7f1e9ac3513539d8b6b6f78e82dbfe0c87d9544bb1a2687a741f459345fff9751d2ae618de1cf58c4cac0904b53346470701
|
data/README.md
CHANGED
@@ -249,3 +249,10 @@ test/services/zoom_webhook_event_processor_test.rb
|
|
249
249
|
|
250
250
|
/Users/owaiskhan/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/diff_test-0.8.0/lib/diff_test/test_suite_execution.rb:43: warning: mismatched indentations at 'end' with 'def' at 41
|
251
251
|
/Users/owaiskhan/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/diff_test-0.8.0/lib/diff_test/test_suite_execution.rb:69: warning: assigned but unused variable - response
|
252
|
+
|
253
|
+
|
254
|
+
overhead of const TracePoint and file path prefix native
|
255
|
+
method_added/const_added
|
256
|
+
|
257
|
+
|
258
|
+
# WRITE test for it setting time from previous successful run
|
data/lib/diff_test/api_client.rb
CHANGED
@@ -5,30 +5,55 @@ module DiffTest
|
|
5
5
|
include HTTParty
|
6
6
|
|
7
7
|
def self.get(path, options = {}, &block)
|
8
|
-
|
8
|
+
process_options(options)
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.post(path, options = {}, &block)
|
13
|
-
|
13
|
+
process_options(options)
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.put(path, options = {}, &block)
|
18
|
-
|
18
|
+
process_options(options)
|
19
19
|
super
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.patch(path, options = {}, &block)
|
23
|
-
|
23
|
+
process_options(options)
|
24
24
|
super
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.delete(path, options = {}, &block)
|
28
|
-
|
28
|
+
process_options(options)
|
29
29
|
super
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.process_options(options)
|
33
|
+
jsonify_body(options)
|
34
|
+
gzip_body(options)
|
35
|
+
set_api_key_in_headers(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.jsonify_body(options)
|
39
|
+
return unless options[:body] && options[:body].is_a?(Hash)
|
40
|
+
options[:body] = options[:body].to_json
|
41
|
+
options[:headers] ||= {}
|
42
|
+
options[:headers]['Content-Type'] = 'application/json'
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.gzip_body(options)
|
46
|
+
return unless options[:body]
|
47
|
+
|
48
|
+
buffer = StringIO.new
|
49
|
+
gz = Zlib::GzipWriter.new(buffer)
|
50
|
+
gz.write(options[:body])
|
51
|
+
gz.close
|
52
|
+
options[:body] = buffer.string
|
53
|
+
options[:headers] ||= {}
|
54
|
+
options[:headers]['Content-Encoding'] = 'gzip'
|
55
|
+
end
|
56
|
+
|
32
57
|
def self.set_api_key_in_headers(options)
|
33
58
|
base_uri DiffTest.configuration.base_api_url
|
34
59
|
options[:headers] ||= {}
|
@@ -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 =
|
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
|
-
|
71
|
-
|
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
|
-
|
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
|
-
|
18
|
-
|
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
|
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
|
@@ -6,9 +6,10 @@ module DiffTest
|
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
super
|
9
|
+
do_line_check = ENV['DIFF_TEST_SKIP_LINE_CHECK'] != '1'
|
9
10
|
@seen_constants = Set.new
|
10
11
|
@tracepoint = TracePoint.new(:call, :b_call) do |event|
|
11
|
-
if DiffTest::Helper.file_in_project?(event.path)
|
12
|
+
if do_line_check && DiffTest::Helper.file_in_project?(event.path)
|
12
13
|
record(DiffTest::Helper.relative_path_from_project_root(event.path))
|
13
14
|
end
|
14
15
|
|
data/lib/diff_test/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2025-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|