test_ids 1.1.1 → 1.2.2

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
  SHA256:
3
- metadata.gz: 306a202dcc8ef6fc823e3f3429e9466674c4a26442a4cb3a10f4ac15b8c8eb9d
4
- data.tar.gz: c20808121f1887cca29eae01ea100f1026a8782dfee389fc5c4600bf23a7e606
3
+ metadata.gz: 99c0a18269234a91b27a3e0329047c5e5a4cbe50ef28679f1f1e81192a845341
4
+ data.tar.gz: 469135ba4071b217135f24f431f60dc9e3bd9730942c957543d9cbd83eed5543
5
5
  SHA512:
6
- metadata.gz: f86d3e0ace61cf2f6f7a0f66b779b6606b7dc474456ced944c6e1a527a9045a364ebb53048a4b29b57da89f15f0d2619c843a61d6339231842131f83d34ee91e
7
- data.tar.gz: 5806f010b4dfa01e6084298ea57994881689a6df815f1235ccd5116b4cf9771dc453fd1fe518d9fa4930a949fcc34da54965286278d3a862908e0281be660c2d
6
+ metadata.gz: 2d5a6d61c38b447d3895ca50357b8cc63241067e11c4582ecb166a0a5c7cf6439c54b8025abff91412c041b968518741eadfd176904e92c1e4db45326d9af9d4
7
+ data.tar.gz: cbf61dfc565216d1aa44ca6bc8f882647888782da5bf4f41a97d34af3015d61629643e4fc37e99ef00b4e52baf1b1d814dcd3ec6a472296060c23aa7702a49cc
@@ -17,7 +17,7 @@ when "test_ids:clear", "test_ids:repair"
17
17
  else
18
18
  @plugin_commands << <<-EOT
19
19
  test_ids:rollback Rollback the TestIds store to the given commit ID
20
- test_ids:clear Clear the assignment database for bins, softbins, numbers or all
20
+ test_ids:clear Clear the assignment database for bins, softbins, numbers, ranges or all for the given configuration database ID
21
21
  test_ids:repair Repair the given database, see -h for more
22
22
  EOT
23
23
 
data/config/version.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  module TestIds
2
2
  MAJOR = 1
3
- MINOR = 1
4
- BUGFIX = 1
3
+ MINOR = 2
4
+ BUGFIX = 2
5
5
  DEV = nil
6
-
7
6
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
8
7
  end
data/lib/test_ids.rb CHANGED
@@ -257,6 +257,24 @@ module TestIds
257
257
  # @reallocate_non_compliant = val
258
258
  # end
259
259
 
260
+ # Reset everything related to the TestIds module
261
+ # only needed for cases where running several targets
262
+ # back to back, e.g. for regression testing
263
+ def reset_everything(are_you_sure: false)
264
+ if are_you_sure
265
+ @repo = nil # accessor
266
+ @git = nil # accessor
267
+ @git_database_dir = nil
268
+ @git_initialized = nil
269
+ @configuration = nil
270
+ @configuration_id = nil
271
+ @bin_config = nil
272
+ @softbin_config = nil
273
+ @number_config = nil
274
+ @publish = nil
275
+ end
276
+ end
277
+
260
278
  private
261
279
 
262
280
  def on_origen_shutdown
@@ -28,60 +28,69 @@ module TestIds
28
28
  # If a numeric number is passed to the softbin, it uses that number.
29
29
  # The configuration for the TestId plugin needs to pass in the bin number and the options from the test flow
30
30
  # For this method to work as intended.
31
- def next_in_range(range, options)
32
- range_item(range, options)
31
+ # This will handle the following range inputs:
32
+ # - Range, Ex: 0..10
33
+ # - Array, Ex: [0..10, 20..30]
34
+ def next_in_range(range_definition, options)
35
+ if range_definition.is_a?(Range)
36
+ range = range_definition.to_a
37
+ elsif range_definition.is_a?(Array)
38
+ range = []
39
+ range_definition.each do |range_element|
40
+ range += range_element.is_a?(Integer) ? [range_element] : range_element.step(options[:size]).to_a
41
+ end
42
+ if range.uniq.size != range.size
43
+ Origen.log.error "Duplicate or overlapping range has been detected in configuration: \'#{TestIds.current_configuration.id}\'."
44
+ fail
45
+ end
46
+ end
47
+ range_item(range, range_definition, options)
33
48
  end
34
49
 
35
- def range_item(range, options)
36
- orig_options = options.dup
37
- # Now Check if the database (JSON file) exists.
38
- # If file exists, load the database and create the alias for ['pointer']['ranges']
39
- if file && File.exist?(file)
40
- lines = File.readlines(file)
41
- # Remove any header comment lines since these are not valid JSON
42
- lines.shift while lines.first =~ /^\/\// && !lines.empty?
43
- s = JSON.load(lines.join("\n"))
44
- rangehash = s['pointers']['ranges']
45
- if rangehash.nil?
46
- rangehash = store['pointers']['ranges'] ||= {}
47
- else
48
- rangehash = Hash[rangehash.map { |k, v| [k.to_sym, v] }]
49
- end
50
+ def range_item(range, range_definition, options)
51
+ # This is the actual fix, it should now not be dependent on the json file being read in, instead the store pointers
52
+ # will be utilized to get the correct number assigned from the range.
53
+ if store['pointers']['ranges'].nil?
54
+ rangehash = {}
50
55
  else
51
- # Create an alias for the databse that stores the pointers per range
52
- rangehash = store['pointers']['ranges'] ||= {}
56
+ rangehash = store['pointers']['ranges']
57
+ rangehash = Hash[rangehash.map { |k, v| [k.to_sym, v] }]
53
58
  end
59
+ orig_options = options.dup
54
60
  # Check the database to see if the passed in range has already been included in the database hash
55
- if rangehash.key?(:"#{range}")
61
+ if rangehash.key?(:"#{range_definition}")
56
62
  # Read out the database hash to see what the last_softbin given out was for that range.
57
63
  # This hash is updated whenever a new softbin is assigned, so it should have the updated values for each range.
58
- previous_assigned_value = rangehash[:"#{range}"].to_i
64
+ previous_assigned_value = rangehash[:"#{range_definition}"].to_i
59
65
  # Now calculate the new pointer.
60
- @pointer = previous_assigned_value - range.min
66
+ @pointer = range.index(previous_assigned_value) + 1
61
67
  # Check if the last_softbin given out is the same as the range[@pointer],
62
68
  # if so increment pointer by softbin size, default size is 1, config.softbins.size is configurable.
63
69
  # from example above, pointer was calculated as 1,range[1] is 10101 and is same as last_softbin, so pointer is incremented
64
70
  # and new value is assigned to the softbin.
65
- if previous_assigned_value == range.to_a[@pointer]
71
+ if previous_assigned_value == range[@pointer]
66
72
  @pointer += options[:size]
67
- assigned_value = range.to_a[@pointer]
73
+ assigned_value = range[@pointer]
68
74
  else
69
75
  # Because of the pointer calculations above, I don't think it will ever reach here, has not in my test cases so far!
70
- assigned_value = range.to_a[@pointer]
76
+ assigned_value = range[@pointer]
71
77
  end
72
78
  # Now update the database pointers to point to the lastest assigned softbin for a given range.
73
- rangehash.merge!(:"#{range}" => "#{range.to_a[@pointer]}")
79
+ rangehash.merge!(:"#{range_definition}" => "#{range[@pointer]}")
74
80
  else
75
81
  # This is the case for a brand new range that has not been passed before
76
82
  # We start from the first value as the assigned softbin and update the database to reflect.
77
83
  @pointer = 0
78
- rangehash.merge!(:"#{range}" => "#{range.to_a[@pointer]}")
79
- assigned_value = range.to_a[@pointer]
84
+ rangehash.merge!(:"#{range_definition}" => "#{range[@pointer]}")
85
+ assigned_value = range[@pointer]
80
86
  end
81
- unless !assigned_value.nil? && assigned_value.between?(range.min, range.max)
87
+ unless !assigned_value.nil? && range.include?(assigned_value)
82
88
  Origen.log.error 'Assigned value not in range'
83
89
  fail
84
90
  end
91
+ # Since the assigned value for this test has now changed, update store to contain the newly assigned value
92
+ # so that when the json file is written, it contains the latest assigned value name.
93
+ store['pointers']['ranges'] = rangehash
85
94
  assigned_value
86
95
  end
87
96
 
@@ -287,7 +296,7 @@ module TestIds
287
296
  end
288
297
  end
289
298
 
290
- # Clear the :bins, :softbins and/or :numbers by setting the options for each item to true
299
+ # Clear the :bins, :softbins and/or :numbers and/or :ranges by setting the options for each item
291
300
  def clear(options)
292
301
  if options[:softbin] || options[:softbins]
293
302
  store['assigned']['softbins'] = {}
@@ -307,6 +316,9 @@ module TestIds
307
316
  store['pointers']['numbers'] = nil
308
317
  store['references']['numbers'] = {}
309
318
  end
319
+ if options[:range] || options[:ranges]
320
+ store['pointers']['ranges'] = nil
321
+ end
310
322
  end
311
323
 
312
324
  # Saves the current allocator state to the repository
@@ -18,6 +18,7 @@ Examples: origen test_ids:clear --bins # Clear the bins in
18
18
  opts.on('--bins', 'Clear the bin database') { options[:bins] = true }
19
19
  opts.on('--softbins', 'Clear the softbin database') { options[:softbins] = true }
20
20
  opts.on('--numbers', 'Clear the test number database') { options[:numbers] = true }
21
+ opts.on('--ranges', 'Clear the ranges database') { options[:ranges] = true }
21
22
  # opts.on('-pl', '--plugin PLUGIN_NAME', String, 'Set current plugin') { |pl_n| options[:current_plugin] = pl_n }
22
23
  opts.on('-d', '--debugger', 'Enable the debugger') { options[:debugger] = true }
23
24
  app_options.each do |app_option|
@@ -38,6 +39,11 @@ begin
38
39
  # Get the commit before the lock to give the user later
39
40
  rollback_id = git.repo.object('HEAD^').sha[0, 11]
40
41
  a = TestIds.load_allocator(ARGV.first)
42
+ if a.nil?
43
+ Origen.log.error "No configuration file could be found for file ID: '#{ARGV.first}'!"
44
+ Origen.log.warn 'By default, the correct ID to pass in will need to match the filename in the form: store_<file id>.json'
45
+ fail
46
+ end
41
47
  a.clear(options)
42
48
  a.save
43
49
  ensure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_ids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-13 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -16,14 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.7.40
19
+ version: 0.57.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.7.40
26
+ version: 0.57.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: dentaku
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dry-inflector
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: origen_testers
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
128
  - !ruby/object:Gem::Version
101
129
  version: 1.8.11
102
130
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.7.7
131
+ rubygems_version: 3.1.4
105
132
  signing_key:
106
133
  specification_version: 4
107
134
  summary: Origen plugin to assign and track test program bins and test numbers