require 'origen' require_relative '../config/application.rb' require 'origen_testers' module TestIds # THIS FILE SHOULD ONLY BE USED TO LOAD RUNTIME DEPENDENCIES # If this plugin has any development dependencies (e.g. dummy DUT or other models that are only used # for testing), then these should be loaded from config/boot.rb require 'test_ids/allocator' require 'test_ids/bin_array' require 'test_ids/configuration' require 'test_ids/git' require 'test_ids/shutdown_handler' require 'test_ids/origen/origen' require 'test_ids/origen_testers/flow' class < User.current.name, 'expires' => (Time.now + @git.minutes(5)).to_f } @git.write('lock.json', JSON.pretty_generate(data)) repo.commit('Obtaining lock') repo.push('origin') end @lock_open = true end end def lsf_shutdown(lsf_publish) if lsf_publish Origen.profile 'Publishing the test IDs store' do data = { 'user' => nil, 'expires' => nil } @git.write('lock.json', JSON.pretty_generate(data)) repo.add # Checkin everything repo.commit('Publishing latest store') repo.push('origin', 'master', force: true) end end end ## When set to true, all numbers generated will be checked to see if they comply ## with the current configuration, and if not they will be re-assigned based on the ## current configuration # def reallocate_non_compliant # @reallocate_non_compliant # end ## When set to true, all numbers generated will be checked to see if they comply ## with the current configuration, and if not they will be re-assigned based on the ## current configuration # def reallocate_non_compliant=(val) # @reallocate_non_compliant = val # end # Reset everything related to the TestIds module # only needed for cases where running several targets # back to back, e.g. for regression testing def reset_everything(are_you_sure: false) if are_you_sure @repo = nil # accessor @git = nil # accessor @git_database_dir = nil @git_initialized = nil @configuration = nil @configuration_id = nil @bin_config = nil @softbin_config = nil @number_config = nil @publish = nil end end private def on_origen_shutdown if !testing? && @configuration if repo @configuration.each do |id, config| config.allocator.save end git.publish if publish? end end end # For testing, clears all instances including the configuration def reset @git = nil @configuration = nil end def clear_configuration_id @configuration_id = nil @bin_config = nil @softbin_config = nil @number_config = nil end def testing=(val) @testing = val end def testing? !!@testing end end end