delta_test 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5124c1d8cd4164ac2b4e697a940dd9c8ac4cee50
4
- data.tar.gz: bd5137e61e6143e541ae75c06c5515d9914831f9
3
+ metadata.gz: a176739129c5821a3db48e783d057a02ac2e7d7f
4
+ data.tar.gz: 76065c7dd622c9b4077431e5a5662a97fbb27d80
5
5
  SHA512:
6
- metadata.gz: 428600dc97de76a3993c0fc544c88f1da90006a7e0e9146b8bce40d1ba92c547d3d3a79b9df1a13578b006eae35636612b79bb478ce13b360f12cb787584f1bd
7
- data.tar.gz: 055945bec6eac5d010e394880d894719a3b3726cb4023c656d14c9b06defb3e5e2635abd775bea4828c6a69abbe6c354620b62689a08da544932db0308d0ec50
6
+ metadata.gz: 5b6a2b75604884e8c1d93929e4c4a3d179392c4df79ed581e7206e69e474553186413c49e1435bca207c905a20fe847435ed0ec2391a7bd3c954e9f7e5ba486a
7
+ data.tar.gz: 7a5df579dfe7ca4a60eebdd863094e7e75cb5584f4dbb5572bd58dd23ac30f3e56246a6a42cc916db6b4b51724b750a488b224e494320f8fddbc259ffeb431b6
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'open3'
2
3
  require 'shellwords'
3
4
  require 'thread'
@@ -111,6 +112,60 @@ module DeltaTest
111
112
  Object.const_defined?(:Bundler) || !!Utils.find_file_upward('Gemfile')
112
113
  end
113
114
 
115
+ ###
116
+ # Wrapper of hook_create_error_file
117
+ #
118
+ # @block
119
+ ###
120
+ def record_error
121
+ hook_create_error_file
122
+ yield if block_given?
123
+ end
124
+
125
+ ###
126
+ # Hook on exit and record errors
127
+ ###
128
+ def hook_create_error_file
129
+ at_exit do
130
+ create_error_file unless current_process_status_success?
131
+ end
132
+ end
133
+
134
+ ###
135
+ # Check exit status of the current process
136
+ #
137
+ # @return {Boolean}
138
+ ###
139
+ def current_process_status_success?
140
+ $!.nil? || $!.is_a?(SystemExit) && $!.success?
141
+ end
142
+
143
+ ###
144
+ # Check if any error is recorded
145
+ #
146
+ # @return {Boolean}
147
+ ###
148
+ def error_recorded?
149
+ File.exists?(error_file)
150
+ end
151
+
152
+ ###
153
+ # Path for an error file
154
+ #
155
+ # @return {Pathname}
156
+ ###
157
+ def error_file
158
+ @error_file ||= DeltaTest.config.tmp_table_file.parent.join('error.txt')
159
+ end
160
+
161
+ ###
162
+ # Create an error file
163
+ ###
164
+ def create_error_file
165
+ FileUtils.mkdir_p(File.dirname(error_file))
166
+ File.new(error_file, 'w')
167
+ end
168
+
114
169
  end
115
170
  end
116
171
  end
@@ -93,7 +93,9 @@ module DeltaTest
93
93
 
94
94
  args += @args
95
95
 
96
- exec_with_data(args.join(' '), @spec_files)
96
+ record_error do
97
+ exec_with_data(args.join(' '), @spec_files)
98
+ end
97
99
  end
98
100
 
99
101
  end
@@ -9,12 +9,16 @@ module DeltaTest
9
9
  class StatsSaveCommand < CommandBase
10
10
 
11
11
  def invoke!
12
+ return if error_recorded?
13
+
12
14
  load_tmp_table_files
13
15
  cleanup_tmp_table_files
14
- save_table_file
15
16
 
16
- stage_table_file
17
- sync_table_file unless @options['no-sync']
17
+ if table.any?
18
+ save_table_file
19
+ stage_table_file
20
+ sync_table_file unless @options['no-sync']
21
+ end
18
22
  end
19
23
 
20
24
  def load_tmp_table_files
@@ -2,7 +2,7 @@ module DeltaTest
2
2
 
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- REVISION = 2
5
+ REVISION = 3
6
6
 
7
7
  VERSION = [MAJOR, MINOR, REVISION].compact.join('.')
8
8
 
@@ -161,4 +161,64 @@ describe DeltaTest::CLI::CommandBase do
161
161
 
162
162
  end
163
163
 
164
+ describe '#error_file' do
165
+
166
+ it 'should return a path for an error file' do
167
+ expect(command_base.error_file).to be_a(Pathname)
168
+ end
169
+
170
+ end
171
+
172
+ describe '#create_error_file' do
173
+
174
+ it 'should create an error file' do
175
+ expect(File.exists?(command_base.error_file)).to be(false)
176
+ command_base.create_error_file
177
+ expect(File.exists?(command_base.error_file)).to be(true)
178
+ end
179
+
180
+ end
181
+
182
+ describe '#error_recorded?' do
183
+
184
+ it 'should return false if no error file exists' do
185
+ expect(File.exists?(command_base.error_file)).to be(false)
186
+ expect(command_base.error_recorded?).to be(false)
187
+ end
188
+
189
+ it 'should return false if an error file exists' do
190
+ command_base.create_error_file
191
+ expect(File.exists?(command_base.error_file)).to be(true)
192
+ expect(command_base.error_recorded?).to be(true)
193
+ end
194
+
195
+ end
196
+
197
+ describe '#record_error' do
198
+
199
+ before do
200
+ allow(command_base).to receive(:hook_create_error_file).and_return(nil)
201
+ end
202
+
203
+ it 'should call hook_create_error_file' do
204
+ expect(command_base).to receive(:hook_create_error_file)
205
+ command_base.record_error
206
+ end
207
+
208
+ it 'should yield a given block' do
209
+ called = false
210
+ command_base.record_error { called = true }
211
+ expect(called).to be(true)
212
+ end
213
+
214
+ end
215
+
216
+ describe '#hook_create_error_file' do
217
+
218
+ end
219
+
220
+ describe '#current_process_status_success?' do
221
+
222
+ end
223
+
164
224
  end
@@ -27,6 +27,8 @@ describe DeltaTest::CLI::ExecCommand do
27
27
 
28
28
  allow(command.stats).to receive(:base_commit).and_return(base_commit)
29
29
  allow(command.stats).to receive(:table_file_path).and_return(nil)
30
+
31
+ allow(command).to receive(:hook_create_error_file).and_return(nil)
30
32
  end
31
33
 
32
34
  describe '#profile_mode?' do
@@ -49,6 +49,11 @@ describe DeltaTest::CLI::StatsSaveCommand do
49
49
 
50
50
  describe '#invoke!' do
51
51
 
52
+ before do
53
+ allow(command.table).to receive(:any?).and_return(true)
54
+ allow(command).to receive(:error_recorded?).and_return(false)
55
+ end
56
+
52
57
  it 'should execute procedures' do
53
58
  expect(command).to receive(:load_tmp_table_files).and_return(nil).once.ordered
54
59
  expect(command).to receive(:cleanup_tmp_table_files).and_return(nil).once.ordered
@@ -73,6 +78,34 @@ describe DeltaTest::CLI::StatsSaveCommand do
73
78
 
74
79
  end
75
80
 
81
+ context 'no table data' do
82
+
83
+ it 'should not create an empty table file' do
84
+ allow(command.table).to receive(:any?).and_return(false)
85
+ expect(command).to receive(:load_tmp_table_files).and_return(nil).once.ordered
86
+ expect(command).to receive(:cleanup_tmp_table_files).and_return(nil).once.ordered
87
+ expect(command).not_to receive(:save_table_file)
88
+ expect(command).not_to receive(:stage_table_file)
89
+ expect(command).not_to receive(:sync_table_file)
90
+ command.invoke!
91
+ end
92
+
93
+ end
94
+
95
+ context 'error_recorded?' do
96
+
97
+ it 'should do nothing' do
98
+ allow(command).to receive(:error_recorded?).and_return(true)
99
+ expect(command).not_to receive(:load_tmp_table_files)
100
+ expect(command).not_to receive(:cleanup_tmp_table_files)
101
+ expect(command).not_to receive(:save_table_file)
102
+ expect(command).not_to receive(:stage_table_file)
103
+ expect(command).not_to receive(:sync_table_file)
104
+ command.invoke!
105
+ end
106
+
107
+ end
108
+
76
109
  end
77
110
 
78
111
  describe '#tmp_table_files' do
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: ../..
13
13
  specs:
14
- delta_test (1.0.1)
14
+ delta_test (1.0.3)
15
15
 
16
16
  GEM
17
17
  remote: https://rubygems.org/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delta_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Iwanaga
@@ -121,7 +121,6 @@ files:
121
121
  - ".gitignore"
122
122
  - ".rspec"
123
123
  - ".ruby-version"
124
- - CHANGELOG.md
125
124
  - Gemfile
126
125
  - LICENSE.txt
127
126
  - README.md
data/CHANGELOG.md DELETED
@@ -1,44 +0,0 @@
1
- Change logs
2
- ===========
3
-
4
- master
5
- ------
6
-
7
- N/A
8
-
9
-
10
- 1.0.1
11
- -----
12
-
13
- - [feature] #26 Subversioning to avoid conflicts
14
-
15
-
16
- 1.0.0
17
- -----
18
-
19
- - [feature] #25 Versioning table files. Including many refactorings and bug fixes
20
-
21
-
22
- 0.2.0
23
- -----
24
-
25
- - [dev] #1 Setup CircleCI. and others
26
- - [dev] #2 Add codeclimate
27
- - [dev] #3 Fix bundle install command in rails directory. and others
28
- - [bugfix] #4 Use hook scope names of rspec v2
29
- - [bugfix] #8 Exit with real status
30
- - [bugfix] #9 Fail to obtain current spec file path with RSpec 2
31
- - [improvement] #12 Use original profiler
32
- - [improvement] #14 Improve profiler
33
- - [improvement] #15 Fully support parallel_tests
34
- - [improvement] #19 Auto bundle exec
35
- - [feature] #20 Run full tests
36
- - [feature] #21 Add clear command
37
-
38
- And many bugfixes and refactorings.
39
-
40
-
41
- 0.1.0
42
- -----
43
-
44
- - The first release