test_ids 1.2.3 → 1.2.4
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/config/application.rb +34 -34
- data/config/boot.rb +4 -2
- data/config/commands.rb +21 -19
- data/config/shared_commands.rb +5 -3
- data/config/version.rb +1 -1
- data/lib/tasks/test_ids.rake +1 -0
- data/lib/test_ids/allocator.rb +156 -150
- data/lib/test_ids/bin_array.rb +13 -12
- data/lib/test_ids/commands/clear.rb +16 -11
- data/lib/test_ids/commands/repair.rb +10 -5
- data/lib/test_ids/configuration.rb +12 -21
- data/lib/test_ids/git.rb +57 -57
- data/lib/test_ids/origen/origen.rb +3 -1
- data/lib/test_ids/origen_testers/flow.rb +9 -9
- data/lib/test_ids/shutdown_handler.rb +2 -0
- data/lib/test_ids.rb +87 -111
- data/lib/test_ids_dev/dut.rb +2 -0
- data/lib/test_ids_dev/interface.rb +3 -1
- data/program/prb1.rb +2 -0
- metadata +19 -24
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module TestIds
|
|
2
4
|
class Configuration
|
|
3
5
|
class Item
|
|
@@ -33,9 +35,8 @@ module TestIds
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def valid?(number)
|
|
36
|
-
if function?
|
|
37
|
-
|
|
38
|
-
end
|
|
38
|
+
fail 'valid? is not supported for algorithm or callback-based assignments' if function?
|
|
39
|
+
|
|
39
40
|
number = number.to_i
|
|
40
41
|
include.include?(number) && !exclude.include?(number)
|
|
41
42
|
end
|
|
@@ -85,22 +86,16 @@ module TestIds
|
|
|
85
86
|
end
|
|
86
87
|
end
|
|
87
88
|
|
|
88
|
-
attr_reader :allocator
|
|
89
|
+
attr_reader :allocator, :id
|
|
89
90
|
|
|
90
91
|
def initialize(id)
|
|
91
92
|
@id = id
|
|
92
93
|
@allocator = Allocator.new(self)
|
|
93
94
|
end
|
|
94
95
|
|
|
95
|
-
def id
|
|
96
|
-
@id
|
|
97
|
-
end
|
|
98
|
-
|
|
99
96
|
def bins(options = {}, &block)
|
|
100
97
|
@bins ||= Item.new
|
|
101
|
-
if block_given?
|
|
102
|
-
@bins.callback(options, &block)
|
|
103
|
-
end
|
|
98
|
+
@bins.callback(options, &block) if block_given?
|
|
104
99
|
@bins
|
|
105
100
|
end
|
|
106
101
|
|
|
@@ -111,9 +106,7 @@ module TestIds
|
|
|
111
106
|
|
|
112
107
|
def softbins(options = {}, &block)
|
|
113
108
|
@softbins ||= Item.new
|
|
114
|
-
if block_given?
|
|
115
|
-
@softbins.callback(options, &block)
|
|
116
|
-
end
|
|
109
|
+
@softbins.callback(options, &block) if block_given?
|
|
117
110
|
@softbins
|
|
118
111
|
end
|
|
119
112
|
|
|
@@ -124,9 +117,7 @@ module TestIds
|
|
|
124
117
|
|
|
125
118
|
def numbers(options = {}, &block)
|
|
126
119
|
@numbers ||= Item.new
|
|
127
|
-
if block_given?
|
|
128
|
-
@numbers.callback(options, &block)
|
|
129
|
-
end
|
|
120
|
+
@numbers.callback(options, &block) if block_given?
|
|
130
121
|
@numbers
|
|
131
122
|
end
|
|
132
123
|
|
|
@@ -152,10 +143,10 @@ module TestIds
|
|
|
152
143
|
end
|
|
153
144
|
|
|
154
145
|
def validate!
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
146
|
+
return if validated?
|
|
147
|
+
|
|
148
|
+
@validated = true
|
|
149
|
+
freeze
|
|
159
150
|
end
|
|
160
151
|
|
|
161
152
|
def empty?
|
data/lib/test_ids/git.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'json'
|
|
2
4
|
require 'git'
|
|
3
5
|
module TestIds
|
|
@@ -20,7 +22,7 @@ module TestIds
|
|
|
20
22
|
|
|
21
23
|
def find
|
|
22
24
|
repos = Dir.glob("#{Origen.app.imports_dir}/test_ids/*.git")
|
|
23
|
-
if repos.
|
|
25
|
+
if repos.empty?
|
|
24
26
|
puts 'No TestIds repositories were found in this application'
|
|
25
27
|
elsif repos.size > 1
|
|
26
28
|
puts
|
|
@@ -29,12 +31,10 @@ module TestIds
|
|
|
29
31
|
repos.each_with_index do |repo, i|
|
|
30
32
|
puts " #{i} - #{Pathname.new(repo).basename}"
|
|
31
33
|
end
|
|
32
|
-
accept = repos.map.with_index { |
|
|
34
|
+
accept = repos.map.with_index { |_r, i| i }
|
|
33
35
|
puts
|
|
34
36
|
selection = repos.size + 1
|
|
35
|
-
until repos[selection]
|
|
36
|
-
selection = get_text(single: true, accept: accept).to_i
|
|
37
|
-
end
|
|
37
|
+
selection = get_text(single: true, accept: accept).to_i until repos[selection]
|
|
38
38
|
else
|
|
39
39
|
selection = 0
|
|
40
40
|
end
|
|
@@ -50,28 +50,28 @@ module TestIds
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def initialize(options)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
return unless !TestIds.lsf_manual_init_shutdown && Origen.running_locally?
|
|
54
|
+
|
|
55
|
+
unless File.exist?("#{options[:local]}/.git")
|
|
56
|
+
FileUtils.rm_rf(options[:local]) if File.exist?(options[:local])
|
|
57
|
+
FileUtils.mkdir_p(options[:local])
|
|
58
|
+
Dir.chdir options[:local] do
|
|
59
|
+
`git clone #{options[:remote]} .`
|
|
60
|
+
unless File.exist?('lock.json')
|
|
61
|
+
# Should really try to use the Git driver for this
|
|
62
|
+
exec 'touch lock.json'
|
|
63
|
+
exec 'git add lock.json'
|
|
64
|
+
exec 'git commit -m "Initial commit"'
|
|
65
|
+
exec 'git push'
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
|
-
@local = options[:local]
|
|
69
|
-
@repo = ::Git.open(options[:local])
|
|
70
|
-
# Get rid of any local edits coming in here, this is only called once at the start
|
|
71
|
-
# of the program generation run.
|
|
72
|
-
# No need to pull latest as that will be done when we obtain a lock.
|
|
73
|
-
@repo.reset_hard
|
|
74
68
|
end
|
|
69
|
+
@local = options[:local]
|
|
70
|
+
@repo = ::Git.open(options[:local])
|
|
71
|
+
# Get rid of any local edits coming in here, this is only called once at the start
|
|
72
|
+
# of the program generation run.
|
|
73
|
+
# No need to pull latest as that will be done when we obtain a lock.
|
|
74
|
+
@repo.reset_hard
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# Roll the repo back to the given commit ID
|
|
@@ -104,19 +104,19 @@ module TestIds
|
|
|
104
104
|
|
|
105
105
|
def exec(cmd)
|
|
106
106
|
r = system(cmd)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
return if r
|
|
108
|
+
|
|
109
|
+
fail "Something went wrong running command: #{cmd}"
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def publish
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
return unless !TestIds.lsf_manual_init_shutdown && Origen.running_locally?
|
|
114
|
+
|
|
115
|
+
Origen.profile 'Publishing the test IDs store' do
|
|
116
|
+
release_lock
|
|
117
|
+
repo.add # Checkin everything
|
|
118
|
+
repo.commit('Publishing latest store')
|
|
119
|
+
repo.push('origin', 'master', force: true)
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
@@ -128,25 +128,25 @@ module TestIds
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def get_lock
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
data = {
|
|
141
|
-
'user' => User.current.name,
|
|
142
|
-
'expires' => (Time.now + minutes(5)).to_f
|
|
143
|
-
}
|
|
144
|
-
write('lock.json', JSON.pretty_generate(data))
|
|
145
|
-
repo.commit('Obtaining lock')
|
|
146
|
-
repo.push('origin')
|
|
131
|
+
return unless !TestIds.lsf_manual_init_shutdown && Origen.running_locally?
|
|
132
|
+
return if @lock_open
|
|
133
|
+
|
|
134
|
+
Origen.profile 'Obtaining test IDs lock' do
|
|
135
|
+
until available_to_lock?(@repo)
|
|
136
|
+
puts
|
|
137
|
+
puts "Waiting for lock, currently locked by #{lock_user} (the lock will expire in less than #{lock_minutes_remaining} #{'minute'.pluralize(lock_minutes_remaining)} if not released before that)"
|
|
138
|
+
puts
|
|
139
|
+
sleep 5
|
|
147
140
|
end
|
|
148
|
-
|
|
141
|
+
data = {
|
|
142
|
+
'user' => User.current.name,
|
|
143
|
+
'expires' => (Time.now + minutes(5)).to_f
|
|
144
|
+
}
|
|
145
|
+
write('lock.json', JSON.pretty_generate(data))
|
|
146
|
+
repo.commit('Obtaining lock')
|
|
147
|
+
repo.push('origin')
|
|
149
148
|
end
|
|
149
|
+
@lock_open = true
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
def release_lock
|
|
@@ -162,11 +162,11 @@ module TestIds
|
|
|
162
162
|
Origen.profile 'Checking for lock' do
|
|
163
163
|
repo_to_use.fetch
|
|
164
164
|
repo_to_use.reset_hard('origin/master')
|
|
165
|
-
if lock_content && lock_user && lock_user != User.current.name
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
result = if lock_content && lock_user && lock_user != User.current.name
|
|
166
|
+
Time.now.to_f > lock_expires
|
|
167
|
+
else
|
|
168
|
+
true
|
|
169
|
+
end
|
|
170
170
|
end
|
|
171
171
|
result
|
|
172
172
|
end
|
|
@@ -185,7 +185,7 @@ module TestIds
|
|
|
185
185
|
|
|
186
186
|
def lock_content
|
|
187
187
|
f = File.join(local, 'lock.json')
|
|
188
|
-
JSON.
|
|
188
|
+
JSON.parse(File.read(f)) if File.exist?(f)
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
def minutes(number)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'origen'
|
|
2
4
|
module Origen
|
|
3
|
-
class <<self
|
|
5
|
+
class << self
|
|
4
6
|
# Override the Origen.reset_interface method to clear out the TestIds
|
|
5
7
|
# configuration, so that it doesn't carry over from one flow to the next
|
|
6
8
|
alias_method :_orig_reset_interface, :reset_interface
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'origen_testers/flow'
|
|
2
4
|
module OrigenTesters
|
|
3
5
|
module Flow
|
|
4
|
-
BIN_OPTS =
|
|
6
|
+
BIN_OPTS = %i(bin softbin bin_size softbin_size number number_size).freeze
|
|
5
7
|
|
|
6
8
|
# Override the flow.test method to inject our generated bin and
|
|
7
9
|
# test numbers
|
|
8
10
|
alias_method :_orig_test, :test
|
|
9
11
|
def test(instance, options = {})
|
|
10
|
-
if TestIds.configured?
|
|
11
|
-
|
|
12
|
-
options[:test_ids_flow_id] = try(:top_level).try(:id) || id
|
|
12
|
+
if TestIds.configured? && options[:test_ids] != :notrack
|
|
13
|
+
options[:test_ids_flow_id] = try(:top_level).try(:id) || id
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
TestIds.current_configuration.allocator.allocate(instance, options)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
17
|
+
unless TestIds.current_configuration.send_to_ate?
|
|
18
|
+
BIN_OPTS.each do |opt|
|
|
19
|
+
options.delete(opt)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
data/lib/test_ids.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'origen'
|
|
2
|
-
require_relative '../config/application
|
|
4
|
+
require_relative '../config/application'
|
|
3
5
|
require 'origen_testers'
|
|
4
6
|
|
|
5
7
|
module TestIds
|
|
@@ -14,7 +16,7 @@ module TestIds
|
|
|
14
16
|
require 'test_ids/origen/origen'
|
|
15
17
|
require 'test_ids/origen_testers/flow'
|
|
16
18
|
|
|
17
|
-
class <<self
|
|
19
|
+
class << self
|
|
18
20
|
# Allocates a number to the given test and returns a new hash containing
|
|
19
21
|
# :bin, :softbin and :number keys.
|
|
20
22
|
#
|
|
@@ -27,8 +29,7 @@ module TestIds
|
|
|
27
29
|
inject_flow_id(opts)
|
|
28
30
|
current_configuration.allocator.allocate(instance, opts)
|
|
29
31
|
{ bin: opts[:bin], bin_size: opts[:bin_size], softbin: opts[:softbin], softbin_size: opts[:softbin_size],
|
|
30
|
-
number: opts[:number], number_size: opts[:number_size]
|
|
31
|
-
}
|
|
32
|
+
number: opts[:number], number_size: opts[:number_size] }
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
# Similar to allocate, but allocates a test number only, i.e. no bin or softbin
|
|
@@ -70,10 +71,10 @@ module TestIds
|
|
|
70
71
|
|
|
71
72
|
# @api private
|
|
72
73
|
def inject_flow_id(options)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
return unless Origen.interface_loaded?
|
|
75
|
+
|
|
76
|
+
flow = Origen.interface.flow
|
|
77
|
+
options[:test_ids_flow_id] = flow.try(:top_level).try(:id) || flow.id
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
# Load an existing allocator, which will be loaded with a configuration based on what has
|
|
@@ -82,11 +83,11 @@ module TestIds
|
|
|
82
83
|
# @api internal
|
|
83
84
|
def load_allocator(id = nil)
|
|
84
85
|
f = TestIds.database_file(id)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
return unless File.exist?(f)
|
|
87
|
+
|
|
88
|
+
a = Configuration.new(id).allocator
|
|
89
|
+
a.load_configuration_from_store
|
|
90
|
+
a
|
|
90
91
|
end
|
|
91
92
|
|
|
92
93
|
def current_configuration
|
|
@@ -95,14 +96,17 @@ module TestIds
|
|
|
95
96
|
|
|
96
97
|
def configuration(id, fail_on_missing = true)
|
|
97
98
|
return @configuration[id] if @configuration && @configuration[id]
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
return unless fail_on_missing
|
|
100
|
+
|
|
101
|
+
fail('You have to create the configuration first before you can access it')
|
|
101
102
|
end
|
|
102
103
|
alias_method :config, :configuration
|
|
103
104
|
|
|
104
105
|
def configure(id = nil, options = {})
|
|
105
|
-
|
|
106
|
+
if id.is_a?(Hash)
|
|
107
|
+
options = id
|
|
108
|
+
id = nil
|
|
109
|
+
end
|
|
106
110
|
|
|
107
111
|
@configuration_id = id || options[:id] || :not_specified
|
|
108
112
|
|
|
@@ -123,9 +127,8 @@ module TestIds
|
|
|
123
127
|
|
|
124
128
|
# Switch the current configuration to the given ID
|
|
125
129
|
def config=(id)
|
|
126
|
-
unless @configuration[id]
|
|
127
|
-
|
|
128
|
-
end
|
|
130
|
+
fail "The TestIds configuration '#{id}' has not been defined yet!" unless @configuration[id]
|
|
131
|
+
|
|
129
132
|
@configuration_id = id
|
|
130
133
|
end
|
|
131
134
|
|
|
@@ -134,26 +137,16 @@ module TestIds
|
|
|
134
137
|
@configuration.ids
|
|
135
138
|
end
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
@bin_config = id
|
|
139
|
-
end
|
|
140
|
+
attr_writer :bin_config, :softbin_config, :number_config
|
|
140
141
|
|
|
141
142
|
def bin_config
|
|
142
143
|
@bin_config ? configuration(@bin_config, false) : current_configuration
|
|
143
144
|
end
|
|
144
145
|
|
|
145
|
-
def softbin_config=(id)
|
|
146
|
-
@softbin_config = id
|
|
147
|
-
end
|
|
148
|
-
|
|
149
146
|
def softbin_config
|
|
150
147
|
@softbin_config ? configuration(@softbin_config, false) : current_configuration
|
|
151
148
|
end
|
|
152
149
|
|
|
153
|
-
def number_config=(id)
|
|
154
|
-
@number_config = id
|
|
155
|
-
end
|
|
156
|
-
|
|
157
150
|
def number_config
|
|
158
151
|
@number_config ? configuration(@number_config, false) : current_configuration
|
|
159
152
|
end
|
|
@@ -184,14 +177,14 @@ module TestIds
|
|
|
184
177
|
# Returns a full path to the database file for the given id, returns nil if
|
|
185
178
|
# git storage has not been enabled
|
|
186
179
|
def database_file(id)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
180
|
+
return unless repo
|
|
181
|
+
|
|
182
|
+
f = if id == :not_specified || !id || id == ''
|
|
183
|
+
'store.json'
|
|
184
|
+
else
|
|
185
|
+
"store_#{id.to_s.downcase}.json"
|
|
186
|
+
end
|
|
187
|
+
"#{git_database_dir}/#{f}"
|
|
195
188
|
end
|
|
196
189
|
|
|
197
190
|
def git_database_dir
|
|
@@ -202,23 +195,16 @@ module TestIds
|
|
|
202
195
|
end
|
|
203
196
|
end
|
|
204
197
|
|
|
205
|
-
|
|
206
|
-
@git
|
|
207
|
-
end
|
|
198
|
+
attr_reader :git, :repo
|
|
208
199
|
|
|
209
200
|
def repo=(val)
|
|
210
201
|
return if @repo && @repo == val
|
|
211
202
|
if @repo && @repo != val
|
|
212
203
|
fail 'You can only use a single test ids repository per program generation run, one per application is recommended'
|
|
213
204
|
end
|
|
214
|
-
if @configuration
|
|
215
|
-
fail 'TestIds.repo must be set before creating the first configuration'
|
|
216
|
-
end
|
|
217
|
-
@repo = val
|
|
218
|
-
end
|
|
205
|
+
fail 'TestIds.repo must be set before creating the first configuration' if @configuration
|
|
219
206
|
|
|
220
|
-
|
|
221
|
-
@repo
|
|
207
|
+
@repo = val
|
|
222
208
|
end
|
|
223
209
|
|
|
224
210
|
def publish?
|
|
@@ -227,22 +213,15 @@ module TestIds
|
|
|
227
213
|
|
|
228
214
|
def publish=(val)
|
|
229
215
|
return if @publish && publish? == val
|
|
230
|
-
if @publish && publish? != val
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
fail 'TestIds.publish must be set before creating the first configuration'
|
|
235
|
-
end
|
|
236
|
-
unless [true, false].include?(val)
|
|
237
|
-
fail 'TestIds.publish must be set to either true or false'
|
|
238
|
-
end
|
|
216
|
+
fail 'You can only use a single setting for publish per program generation run' if @publish && publish? != val
|
|
217
|
+
fail 'TestIds.publish must be set before creating the first configuration' if @configuration
|
|
218
|
+
fail 'TestIds.publish must be set to either true or false' unless [true, false].include?(val)
|
|
219
|
+
|
|
239
220
|
@publish = val ? :save : :dont_save
|
|
240
221
|
end
|
|
241
222
|
|
|
242
223
|
def lsf_manual_init_shutdown
|
|
243
|
-
if @lsf_manual_init_shutdown
|
|
244
|
-
true
|
|
245
|
-
end
|
|
224
|
+
true if @lsf_manual_init_shutdown
|
|
246
225
|
false
|
|
247
226
|
end
|
|
248
227
|
|
|
@@ -275,39 +254,39 @@ module TestIds
|
|
|
275
254
|
# No need to pull latest as that will be done when we obtain a lock.
|
|
276
255
|
@repo.reset_hard
|
|
277
256
|
@git = Git.new(local: local_var_git_database_dir, remote: @repo)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
data = {
|
|
288
|
-
'user' => User.current.name,
|
|
289
|
-
'expires' => (Time.now + @git.minutes(5)).to_f
|
|
290
|
-
}
|
|
291
|
-
@git.write('lock.json', JSON.pretty_generate(data))
|
|
292
|
-
repo.commit('Obtaining lock')
|
|
293
|
-
repo.push('origin')
|
|
257
|
+
return unless lsf_publish
|
|
258
|
+
return if @lock_open
|
|
259
|
+
|
|
260
|
+
Origen.profile 'Obtaining test IDs lock' do
|
|
261
|
+
until @git.available_to_lock?(@repo)
|
|
262
|
+
puts
|
|
263
|
+
puts "Waiting for lock, currently locked by #{@git.lock_user} (the lock will expire in less than #{@git.lock_minutes_remaining} #{'minute'.pluralize(@git.lock_minutes_remaining)} if not released before that)"
|
|
264
|
+
puts
|
|
265
|
+
sleep 5
|
|
294
266
|
end
|
|
295
|
-
|
|
267
|
+
data = {
|
|
268
|
+
'user' => User.current.name,
|
|
269
|
+
'expires' => (Time.now + @git.minutes(5)).to_f
|
|
270
|
+
}
|
|
271
|
+
@git.write('lock.json', JSON.pretty_generate(data))
|
|
272
|
+
repo.commit('Obtaining lock')
|
|
273
|
+
repo.push('origin')
|
|
296
274
|
end
|
|
275
|
+
@lock_open = true
|
|
297
276
|
end
|
|
298
277
|
|
|
299
278
|
def lsf_shutdown(lsf_publish)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
279
|
+
return unless lsf_publish
|
|
280
|
+
|
|
281
|
+
Origen.profile 'Publishing the test IDs store' do
|
|
282
|
+
data = {
|
|
283
|
+
'user' => nil,
|
|
284
|
+
'expires' => nil
|
|
285
|
+
}
|
|
286
|
+
@git.write('lock.json', JSON.pretty_generate(data))
|
|
287
|
+
repo.add # Checkin everything
|
|
288
|
+
repo.commit('Publishing latest store')
|
|
289
|
+
repo.push('origin', 'master', force: true)
|
|
311
290
|
end
|
|
312
291
|
end
|
|
313
292
|
|
|
@@ -329,31 +308,30 @@ module TestIds
|
|
|
329
308
|
# only needed for cases where running several targets
|
|
330
309
|
# back to back, e.g. for regression testing
|
|
331
310
|
def reset_everything(are_you_sure: false)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
311
|
+
return unless are_you_sure
|
|
312
|
+
|
|
313
|
+
@repo = nil # accessor
|
|
314
|
+
@git = nil # accessor
|
|
315
|
+
@git_database_dir = nil
|
|
316
|
+
@git_initialized = nil
|
|
317
|
+
@configuration = nil
|
|
318
|
+
@configuration_id = nil
|
|
319
|
+
@bin_config = nil
|
|
320
|
+
@softbin_config = nil
|
|
321
|
+
@number_config = nil
|
|
322
|
+
@publish = nil
|
|
344
323
|
end
|
|
345
324
|
|
|
346
325
|
private
|
|
347
326
|
|
|
348
327
|
def on_origen_shutdown
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
git.publish if publish?
|
|
355
|
-
end
|
|
328
|
+
return unless !testing? && @configuration
|
|
329
|
+
return unless repo
|
|
330
|
+
|
|
331
|
+
@configuration.each do |_id, config|
|
|
332
|
+
config.allocator.save
|
|
356
333
|
end
|
|
334
|
+
git.publish if publish?
|
|
357
335
|
end
|
|
358
336
|
|
|
359
337
|
# For testing, clears all instances including the configuration
|
|
@@ -369,9 +347,7 @@ module TestIds
|
|
|
369
347
|
@number_config = nil
|
|
370
348
|
end
|
|
371
349
|
|
|
372
|
-
|
|
373
|
-
@testing = val
|
|
374
|
-
end
|
|
350
|
+
attr_writer :testing
|
|
375
351
|
|
|
376
352
|
def testing?
|
|
377
353
|
!!@testing
|
data/lib/test_ids_dev/dut.rb
CHANGED