origen 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/origen +3 -1
- data/config/boot.rb +1 -7
- data/config/commands.rb +0 -1
- data/config/version.rb +2 -2
- data/lib/c99/{j750_interface.rb → ate_interface.rb} +3 -11
- data/lib/c99/doc_interface.rb +1 -1
- data/lib/origen.rb +9 -30
- data/lib/origen/application.rb +10 -8
- data/lib/origen/application/configuration.rb +13 -26
- data/lib/origen/application/plugins.rb +122 -0
- data/lib/origen/application/plugins_manager.rb +16 -254
- data/lib/origen/application/release.rb +2 -2
- data/lib/origen/application/runner.rb +2 -4
- data/lib/origen/chips.rb +0 -0
- data/lib/origen/chips/chip.rb +0 -0
- data/lib/origen/chips/design_entry.rb +0 -0
- data/lib/origen/chips/doc_entry.rb +0 -0
- data/lib/origen/chips/note.rb +0 -0
- data/lib/origen/commands.rb +4 -44
- data/lib/origen/commands/compile.rb +1 -2
- data/lib/origen/commands/generate.rb +1 -1
- data/lib/origen/commands/interactive.rb +1 -2
- data/lib/origen/commands/plugin.rb +49 -56
- data/lib/origen/commands/program.rb +1 -1
- data/lib/origen/commands/rc.rb +2 -2
- data/lib/origen/commands/version.rb +2 -17
- data/lib/origen/commands_global.rb +3 -0
- data/lib/origen/file_handler.rb +10 -10
- data/lib/origen/generator.rb +1 -1
- data/lib/origen/generator/job.rb +1 -1
- data/lib/origen/generator/pattern.rb +2 -2
- data/lib/origen/generator/pattern_finder.rb +10 -9
- data/lib/origen/pins/pin.rb +0 -0
- data/lib/origen/regression_manager.rb +0 -0
- data/lib/origen/remote_manager.rb +2 -8
- data/lib/origen/revision_control/design_sync.rb +0 -0
- data/lib/origen/revision_control/git.rb +0 -0
- data/lib/origen/specs.rb +0 -0
- data/lib/origen/specs/checkers.rb +0 -0
- data/lib/origen/specs/creation_info.rb +0 -0
- data/lib/origen/specs/exhibit.rb +0 -0
- data/lib/origen/specs/spec.rb +0 -0
- data/lib/origen/utility.rb +0 -1
- data/lib/origen/utility/diff.rb +0 -0
- metadata +42 -119
- data/lib/origen/import_manager.rb +0 -596
- data/lib/origen/nvm.rb +0 -6
- data/lib/origen/nvm/block_array.rb +0 -72
- data/lib/origen/tester.rb +0 -56
- data/lib/origen/tester/api.rb +0 -277
- data/lib/origen/tester/bdm/bdm.rb +0 -25
- data/lib/origen/tester/doc/doc.rb +0 -226
- data/lib/origen/tester/doc/generator.rb +0 -126
- data/lib/origen/tester/doc/generator/flow.rb +0 -71
- data/lib/origen/tester/doc/generator/flow_line.rb +0 -203
- data/lib/origen/tester/doc/generator/test.rb +0 -68
- data/lib/origen/tester/doc/generator/test_group.rb +0 -66
- data/lib/origen/tester/doc/generator/tests.rb +0 -47
- data/lib/origen/tester/doc/model.rb +0 -162
- data/lib/origen/tester/generator.rb +0 -271
- data/lib/origen/tester/generator/flow_control_api.rb +0 -606
- data/lib/origen/tester/generator/identity_map.rb +0 -25
- data/lib/origen/tester/generator/placeholder.rb +0 -13
- data/lib/origen/tester/generator/test_numberer.rb +0 -25
- data/lib/origen/tester/interface.rb +0 -154
- data/lib/origen/tester/j750/files.rb +0 -45
- data/lib/origen/tester/j750/generator.rb +0 -203
- data/lib/origen/tester/j750/generator/flow.rb +0 -123
- data/lib/origen/tester/j750/generator/flow_line.rb +0 -288
- data/lib/origen/tester/j750/generator/patgroup.rb +0 -111
- data/lib/origen/tester/j750/generator/patgroups.rb +0 -41
- data/lib/origen/tester/j750/generator/patset.rb +0 -111
- data/lib/origen/tester/j750/generator/patsets.rb +0 -41
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +0 -9
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +0 -16
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +0 -8
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +0 -10
- data/lib/origen/tester/j750/generator/test_instance.rb +0 -846
- data/lib/origen/tester/j750/generator/test_instance_group.rb +0 -60
- data/lib/origen/tester/j750/generator/test_instances.rb +0 -182
- data/lib/origen/tester/j750/j750.rb +0 -845
- data/lib/origen/tester/j750/j750_hpt.rb +0 -35
- data/lib/origen/tester/j750/parser.rb +0 -104
- data/lib/origen/tester/j750/parser/ac_spec.rb +0 -11
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +0 -36
- data/lib/origen/tester/j750/parser/dc_specs.rb +0 -50
- data/lib/origen/tester/j750/parser/descriptions.rb +0 -340
- data/lib/origen/tester/j750/parser/flow.rb +0 -111
- data/lib/origen/tester/j750/parser/flow_line.rb +0 -207
- data/lib/origen/tester/j750/parser/flows.rb +0 -23
- data/lib/origen/tester/j750/parser/pattern_set.rb +0 -94
- data/lib/origen/tester/j750/parser/pattern_sets.rb +0 -33
- data/lib/origen/tester/j750/parser/test_instance.rb +0 -322
- data/lib/origen/tester/j750/parser/test_instances.rb +0 -26
- data/lib/origen/tester/j750/parser/timeset.rb +0 -15
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/jlink/jlink.rb +0 -33
- data/lib/origen/tester/parser.rb +0 -24
- data/lib/origen/tester/parser/description_lookup.rb +0 -64
- data/lib/origen/tester/parser/searchable_array.rb +0 -32
- data/lib/origen/tester/parser/searchable_hash.rb +0 -32
- data/lib/origen/tester/time.rb +0 -338
- data/lib/origen/tester/timing.rb +0 -253
- data/lib/origen/tester/ultraflex/files.rb +0 -45
- data/lib/origen/tester/ultraflex/generator.rb +0 -200
- data/lib/origen/tester/ultraflex/generator/flow.rb +0 -119
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +0 -269
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +0 -111
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +0 -41
- data/lib/origen/tester/ultraflex/generator/patset.rb +0 -111
- data/lib/origen/tester/ultraflex/generator/patsets.rb +0 -41
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +0 -9
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +0 -16
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +0 -8
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +0 -10
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +0 -622
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +0 -60
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +0 -174
- data/lib/origen/tester/ultraflex/parser.rb +0 -104
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +0 -11
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +0 -36
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +0 -50
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +0 -342
- data/lib/origen/tester/ultraflex/parser/flow.rb +0 -111
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +0 -207
- data/lib/origen/tester/ultraflex/parser/flows.rb +0 -23
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +0 -94
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +0 -33
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +0 -262
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +0 -26
- data/lib/origen/tester/ultraflex/parser/timeset.rb +0 -15
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +0 -759
- data/lib/origen/tester/v93k/generator.rb +0 -80
- data/lib/origen/tester/v93k/generator/flow.rb +0 -63
- data/lib/origen/tester/v93k/generator/flow_node.rb +0 -17
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +0 -10
- data/lib/origen/tester/v93k/generator/pattern.rb +0 -16
- data/lib/origen/tester/v93k/generator/pattern_master.rb +0 -54
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +0 -6
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +0 -11
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +0 -121
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +0 -9
- data/lib/origen/tester/v93k/generator/test_function.rb +0 -103
- data/lib/origen/tester/v93k/generator/test_functions.rb +0 -79
- data/lib/origen/tester/v93k/generator/test_method.rb +0 -46
- data/lib/origen/tester/v93k/generator/test_methods.rb +0 -75
- data/lib/origen/tester/v93k/generator/test_suite.rb +0 -54
- data/lib/origen/tester/v93k/generator/test_suites.rb +0 -65
- data/lib/origen/tester/v93k/v93k.rb +0 -420
- data/lib/origen/tester/vector.rb +0 -86
- data/lib/origen/tester/vector_generator.rb +0 -637
- data/lib/origen/tester/vector_pipeline.rb +0 -150
- data/lib/origen/utility/design_sync.rb +0 -494
- data/lib/origen/version_checker.rb +0 -117
@@ -1,66 +0,0 @@
|
|
1
|
-
module Origen
|
2
|
-
module Tester
|
3
|
-
class Doc
|
4
|
-
module Generator
|
5
|
-
class TestGroup
|
6
|
-
attr_accessor :name, :version, :append_version
|
7
|
-
|
8
|
-
include Enumerable
|
9
|
-
|
10
|
-
def initialize(name, _options = {})
|
11
|
-
@name = name
|
12
|
-
@store = []
|
13
|
-
@append_version = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def name
|
17
|
-
if unversioned_name
|
18
|
-
if version && @append_version
|
19
|
-
"#{unversioned_name}_v#{version}"
|
20
|
-
else
|
21
|
-
unversioned_name.to_s
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_yaml(options = {})
|
27
|
-
y = {}
|
28
|
-
y['group'] = @store.map { |t| t.to_yaml(options) }
|
29
|
-
y
|
30
|
-
end
|
31
|
-
|
32
|
-
def unversioned_name
|
33
|
-
if @name
|
34
|
-
if @name =~ /grp$/
|
35
|
-
@name
|
36
|
-
else
|
37
|
-
"#{@name}_grp"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def <<(instance)
|
43
|
-
@store << instance
|
44
|
-
end
|
45
|
-
|
46
|
-
def size
|
47
|
-
@store.size
|
48
|
-
end
|
49
|
-
|
50
|
-
def each
|
51
|
-
@store.each { |ins| yield ins }
|
52
|
-
end
|
53
|
-
|
54
|
-
def ==(other_instance_group)
|
55
|
-
self.class == other_instance_group.class &&
|
56
|
-
unversioned_name.to_s == other_instance_group.unversioned_name.to_s &&
|
57
|
-
size == other_instance_group.size &&
|
58
|
-
self.all? do |ins|
|
59
|
-
other_instance_group.any? { |other_ins| ins == other_ins }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Origen
|
2
|
-
module Tester
|
3
|
-
class Doc
|
4
|
-
module Generator
|
5
|
-
class Tests
|
6
|
-
attr_accessor :collection
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@collection = []
|
10
|
-
end
|
11
|
-
|
12
|
-
class IndexedString < ::String
|
13
|
-
attr_accessor :index
|
14
|
-
|
15
|
-
def name
|
16
|
-
self
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def add(name, attrs = {})
|
21
|
-
test = Test.new(name, attrs)
|
22
|
-
if @current_group
|
23
|
-
@current_group << test
|
24
|
-
else
|
25
|
-
collection << test
|
26
|
-
end
|
27
|
-
test
|
28
|
-
end
|
29
|
-
|
30
|
-
# Arbitrarily group a subset of tests together, see the J750 API for details on how to use
|
31
|
-
# this.
|
32
|
-
def group(name = nil, options = {})
|
33
|
-
name, options = nil, name if name.is_a?(Hash)
|
34
|
-
@current_group = TestGroup.new(name, options)
|
35
|
-
collection << @current_group
|
36
|
-
yield @current_group
|
37
|
-
@current_group = nil
|
38
|
-
end
|
39
|
-
alias_method :add_group, :group
|
40
|
-
|
41
|
-
def render(_file, _options = {})
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,162 +0,0 @@
|
|
1
|
-
module Origen
|
2
|
-
module Tester
|
3
|
-
class Doc
|
4
|
-
# Class representing a program model, provides an API to iterate
|
5
|
-
# on the flow based on context (e.g. which job).
|
6
|
-
class Model
|
7
|
-
attr_accessor :flows, :target
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@flows = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
# Iterates through each line in the given flow returning a hash for each
|
14
|
-
# line with the following structure:
|
15
|
-
#
|
16
|
-
# {
|
17
|
-
# :type => Symbol, # Type of flow line
|
18
|
-
# :description => [], # Array of strings
|
19
|
-
# :instance => [{}], # Array of attributes hashes (each one represents an individual test instance)
|
20
|
-
# :flow => {}, # Hash of attributes
|
21
|
-
# :context => {}, # Hash of attributes
|
22
|
-
# }
|
23
|
-
#
|
24
|
-
# In all cases if an item is missing then it will be replaced by an empty
|
25
|
-
# array or hash as appropriate so that the caller does not need to worry
|
26
|
-
# about this.
|
27
|
-
#
|
28
|
-
# Supply the name of the flow(s) to consider, if the flows argument is left
|
29
|
-
# out then all lines in all flows will be returned.
|
30
|
-
#
|
31
|
-
# A context option can be supplied to only return the tests for which the given
|
32
|
-
# context is true.
|
33
|
-
#
|
34
|
-
# puts "The following tests run at FR:"
|
35
|
-
# program_model.each_in_flow(:ft_flow, :context => { :job => "FR" }) do |line|
|
36
|
-
# puts " #{line[:flow][:name]}"
|
37
|
-
# end
|
38
|
-
def each_in_flow(flows = nil, options = {})
|
39
|
-
if flows.is_a?(Hash)
|
40
|
-
options = flows
|
41
|
-
flows = nil
|
42
|
-
end
|
43
|
-
unless flows
|
44
|
-
flows = self.flows.keys
|
45
|
-
end
|
46
|
-
[flows].flatten.each do |flow|
|
47
|
-
@flows[flow.to_sym].each do |test|
|
48
|
-
test = format_test(test)
|
49
|
-
if valid_in_context?(test, options[:context])
|
50
|
-
yield test
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
|
57
|
-
# Searches the given flows to find dependents of the given test id. The dependents
|
58
|
-
# are returned in arrays grouped by context:
|
59
|
-
#
|
60
|
-
# {
|
61
|
-
# :if_failed => [],
|
62
|
-
# :if_passed => [],
|
63
|
-
# :if_ran => [],
|
64
|
-
# :unless_ran => [],
|
65
|
-
# }
|
66
|
-
#
|
67
|
-
# Each test will have the same format as described in #each_in_flow.
|
68
|
-
#
|
69
|
-
# If no dependents are found an empty hash is returned.
|
70
|
-
def dependents_of(id, flows, options = {})
|
71
|
-
d = {}
|
72
|
-
each_in_flow(flows, options) do |test|
|
73
|
-
test[:context].each do |key, val|
|
74
|
-
if val == id
|
75
|
-
d[key] ||= []
|
76
|
-
d[key] << test
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
d
|
81
|
-
end
|
82
|
-
|
83
|
-
# Search for the given test id in the given flows.
|
84
|
-
# Returns nil if not found.
|
85
|
-
def find_by_id(id, flows, options = {})
|
86
|
-
each_in_flow(flows, options) do |test|
|
87
|
-
return test if test[:flow][:id] == id
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Returns true if the given tests id valid under the given context
|
92
|
-
# (currently only tests for job matching)
|
93
|
-
def valid_in_context?(test, context = nil)
|
94
|
-
if context && context[:job] && test[:context]
|
95
|
-
if test[:context][:if_jobs]
|
96
|
-
test[:context][:if_jobs].include?(context[:job])
|
97
|
-
elsif test[:context][:unless_jobs]
|
98
|
-
!test[:context][:unless_jobs].include?(context[:job])
|
99
|
-
else
|
100
|
-
true
|
101
|
-
end
|
102
|
-
else
|
103
|
-
true
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# @api private
|
108
|
-
def format_test(test, _options = {})
|
109
|
-
{
|
110
|
-
type: test[:type] ? test[:type].to_sym : :unknown,
|
111
|
-
description: test[:description] || [],
|
112
|
-
instance: build_instance(test),
|
113
|
-
flow: test[:flow] ? test[:flow][:attributes] || {} : {},
|
114
|
-
context: test[:flow] ? test[:flow][:context] || {} : {}
|
115
|
-
}
|
116
|
-
end
|
117
|
-
|
118
|
-
# @api private
|
119
|
-
def build_instance(test)
|
120
|
-
if test[:instance]
|
121
|
-
if test[:instance][:group]
|
122
|
-
test[:instance][:group].map { |g| g[:attributes] || {} }
|
123
|
-
else
|
124
|
-
[test[:instance][:attributes] || {}]
|
125
|
-
end
|
126
|
-
else
|
127
|
-
[{}]
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# YAML likes strings for keys, we don't, so make sure all keys are symbols
|
132
|
-
# when receiving a new flow
|
133
|
-
# @api private
|
134
|
-
def add_flow(name, content)
|
135
|
-
@flows[name.to_sym] = content.map do |h|
|
136
|
-
h = symbolize_keys h
|
137
|
-
if h[:instance] && h[:instance][:group]
|
138
|
-
h[:instance][:group] = h[:instance][:group].map { |j| symbolize_keys j }
|
139
|
-
end
|
140
|
-
h
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
# @api private
|
145
|
-
def symbolize_keys(hash)
|
146
|
-
hash.reduce({}) do |result, (key, value)|
|
147
|
-
new_key = case key
|
148
|
-
when String then key.to_sym
|
149
|
-
else key
|
150
|
-
end
|
151
|
-
new_value = case value
|
152
|
-
when Hash then symbolize_keys(value)
|
153
|
-
else value
|
154
|
-
end
|
155
|
-
result[new_key] = new_value
|
156
|
-
result
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
@@ -1,271 +0,0 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
require 'erb'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
module Origen
|
6
|
-
module Tester
|
7
|
-
module Generator
|
8
|
-
autoload :Placeholder, 'origen/tester/generator/placeholder'
|
9
|
-
autoload :IdentityMap, 'origen/tester/generator/identity_map'
|
10
|
-
autoload :FlowControlAPI, 'origen/tester/generator/flow_control_api'
|
11
|
-
|
12
|
-
extend ActiveSupport::Concern
|
13
|
-
|
14
|
-
included do
|
15
|
-
include Origen::Generator::Comparator
|
16
|
-
end
|
17
|
-
|
18
|
-
# The program source files are executed by eval to allow the tester to filter the
|
19
|
-
# source contents before executing. For examples the doc tester replaces all comments
|
20
|
-
# with a method call containing each comment so that they can be captured.
|
21
|
-
def self.execute_source(file)
|
22
|
-
if Origen.tester.doc? && Origen.interface_loaded? && Origen.interface.respond_to?(:filter_source)
|
23
|
-
File.open(file) do |f|
|
24
|
-
src = f.read
|
25
|
-
src = Origen.interface.filter_source(src)
|
26
|
-
# With source file wrapping here to ensure that any calls to Origen.app! within
|
27
|
-
# the source code will evaluate to the correct app instance
|
28
|
-
Origen.with_source_file(file) do
|
29
|
-
eval(src, global_binding)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
else
|
33
|
-
load file
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# When called on a generater no output files will be created from it
|
38
|
-
def inhibit_output
|
39
|
-
@inhibit_output = true
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns true if the output files from this generator will be inhibited
|
43
|
-
def output_inhibited?
|
44
|
-
@inhibit_output
|
45
|
-
end
|
46
|
-
|
47
|
-
# Expands and inserts all render statements that have been encountered
|
48
|
-
def close(options = {})
|
49
|
-
Origen.profile "closing #{filename}" do
|
50
|
-
base_collection = collection
|
51
|
-
base_collection.each_with_index do |item, i|
|
52
|
-
if item.is_a? Placeholder
|
53
|
-
if item.type == :render
|
54
|
-
txt = ''
|
55
|
-
Origen.file_handler.preserve_current_file do
|
56
|
-
Origen.file_handler.default_extension = file_extension
|
57
|
-
placeholder = compiler.render(item.file, item.options)
|
58
|
-
txt = compiler.insert(placeholder).chomp
|
59
|
-
end
|
60
|
-
base_collection[i] = txt
|
61
|
-
else
|
62
|
-
fail 'Unknown placeholder encountered!'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
@collection = base_collection.flatten.compact
|
67
|
-
on_close(options)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def file_pipeline
|
72
|
-
@@file_pipeline ||= []
|
73
|
-
end
|
74
|
-
|
75
|
-
# Returns the directory of the current source file being generated
|
76
|
-
def current_dir
|
77
|
-
if file_pipeline.empty?
|
78
|
-
Origen.file_handler.base_directory
|
79
|
-
else
|
80
|
-
Pathname.new(file_pipeline.last).dirname
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# Redefine this in the parent which includes this module if you want anything to
|
85
|
-
# occur after closing the generator (expanding all render/import statements) but
|
86
|
-
# before writing to a file.
|
87
|
-
def on_close(_options = {})
|
88
|
-
end
|
89
|
-
|
90
|
-
# Redefine this in the parent which includes this module if you want anything to
|
91
|
-
# occur after all tests have been generated but before file writing starts.
|
92
|
-
def finalize(_options = {})
|
93
|
-
end
|
94
|
-
|
95
|
-
def compiler
|
96
|
-
Origen.generator.compiler
|
97
|
-
end
|
98
|
-
|
99
|
-
def filename=(name)
|
100
|
-
@filename = name
|
101
|
-
end
|
102
|
-
|
103
|
-
def filename(options = {})
|
104
|
-
options = {
|
105
|
-
include_extension: true
|
106
|
-
}.merge(options)
|
107
|
-
name = (@filename || Origen.file_handler.current_file.basename('.rb')).to_s
|
108
|
-
if Origen.config.program_prefix
|
109
|
-
unless name =~ /^#{Origen.config.program_prefix}/i
|
110
|
-
name = "#{Origen.config.program_prefix}_#{name}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
f = Pathname.new(name).basename
|
114
|
-
ext = f.extname.empty? ? file_extension : f.extname
|
115
|
-
body = f.basename(".#{ext}").to_s
|
116
|
-
body.gsub!('_resources', '')
|
117
|
-
if defined? self.class::OUTPUT_POSTFIX
|
118
|
-
# Unless the postfix is already in the name
|
119
|
-
unless body =~ /#{self.class::OUTPUT_POSTFIX}$/i
|
120
|
-
body = "#{body}_#{self.class::OUTPUT_POSTFIX}"
|
121
|
-
end
|
122
|
-
end
|
123
|
-
ext = ".#{ext}" unless ext =~ /^\./
|
124
|
-
if options[:include_extension]
|
125
|
-
"#{body}#{ext}"
|
126
|
-
else
|
127
|
-
"#{body}"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def dont_diff=(val)
|
132
|
-
@dont_diff = val
|
133
|
-
end
|
134
|
-
|
135
|
-
# All generators must implement a collection method that returns an
|
136
|
-
# array containing the generated items
|
137
|
-
def collection
|
138
|
-
@collection ||= []
|
139
|
-
end
|
140
|
-
|
141
|
-
def collection=(array)
|
142
|
-
@collection = array
|
143
|
-
end
|
144
|
-
|
145
|
-
def file_extension
|
146
|
-
if defined? self.class::OUTPUT_EXTENSION
|
147
|
-
self.class::OUTPUT_EXTENSION
|
148
|
-
elsif defined? self.class::TEMPLATE
|
149
|
-
p = Pathname.new(self.class::TEMPLATE)
|
150
|
-
ext = p.basename('.erb').extname
|
151
|
-
ext.empty? ? 'txt' : ext
|
152
|
-
else
|
153
|
-
'txt'
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def write_to_file(options = {})
|
158
|
-
unless output_inhibited?
|
159
|
-
if defined? self.class::TEMPLATE || Origen.tester.is_a?(Origen::Tester::Doc)
|
160
|
-
write_from_template(options)
|
161
|
-
else
|
162
|
-
fail "Don't know hot to write without a template!"
|
163
|
-
end
|
164
|
-
stats.completed_files += 1
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def write_from_template(options = {})
|
169
|
-
options = {
|
170
|
-
quiet: false,
|
171
|
-
skip_diff: false
|
172
|
-
}.merge(options)
|
173
|
-
unless output_inhibited?
|
174
|
-
# If this is not the first time we have written to the current output file
|
175
|
-
# then appen to it, otherwise clear it and start from scratch.
|
176
|
-
# The use of a class variable to store the opened files means that it will be
|
177
|
-
# shared by all generators in this run.
|
178
|
-
@@opened_files ||= []
|
179
|
-
if @@opened_files.include?(output_file) && !Origen.tester.is_a?(Origen::Tester::Doc)
|
180
|
-
@append = true
|
181
|
-
Origen.file_handler.preserve_state do
|
182
|
-
File.open(output_file, 'a') do |out|
|
183
|
-
content = compiler.insert(ERB.new(File.read(self.class::TEMPLATE), 0, Origen.config.erb_trim_mode).result(binding))
|
184
|
-
out.puts content unless content.empty?
|
185
|
-
end
|
186
|
-
end
|
187
|
-
Origen.log.info "Appending... #{output_file.basename}" unless options[:quiet]
|
188
|
-
else
|
189
|
-
@append = false
|
190
|
-
Origen.file_handler.preserve_state do
|
191
|
-
if Origen.tester.is_a?(Origen::Tester::Doc)
|
192
|
-
if options[:return_model]
|
193
|
-
Origen::Tester::Doc.model.add_flow(filename(include_extension: false), to_yaml)
|
194
|
-
else
|
195
|
-
Origen.file_handler.open_for_write(output_file) do |f|
|
196
|
-
f.puts YAML.dump(to_yaml(include_descriptions: false))
|
197
|
-
end
|
198
|
-
end
|
199
|
-
else
|
200
|
-
File.open(output_file, 'w') do |out|
|
201
|
-
out.puts compiler.insert(ERB.new(File.read(self.class::TEMPLATE), 0, Origen.config.erb_trim_mode).result(binding))
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
@@opened_files << output_file
|
206
|
-
Origen.log.info "Writing... #{output_file.basename}" unless options[:quiet]
|
207
|
-
end
|
208
|
-
if !@dont_diff && !options[:skip_diff] && !options[:quiet]
|
209
|
-
check_for_changes(output_file, reference_file,
|
210
|
-
compile_job: true,
|
211
|
-
comment_char: Origen.app.tester.program_comment_char)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
def output_file
|
217
|
-
Pathname.new("#{Origen.file_handler.output_directory}/#{filename}")
|
218
|
-
end
|
219
|
-
|
220
|
-
def reference_file
|
221
|
-
Pathname.new("#{Origen.file_handler.reference_directory}/#{filename}")
|
222
|
-
end
|
223
|
-
|
224
|
-
def import(file, options = {})
|
225
|
-
file = Pathname.new(file).absolute? ? file : "#{current_dir}/#{file}"
|
226
|
-
file = Origen.file_handler.clean_path_to_sub_program(file)
|
227
|
-
base_collection = collection
|
228
|
-
@collection = []
|
229
|
-
Origen.generator.option_pipeline << options
|
230
|
-
file_pipeline << file
|
231
|
-
Origen::Tester::Generator.execute_source(file)
|
232
|
-
file_pipeline.pop
|
233
|
-
base_collection << @collection
|
234
|
-
@collection = base_collection.flatten
|
235
|
-
end
|
236
|
-
|
237
|
-
def render(file, options = {})
|
238
|
-
if options.delete(:_inline)
|
239
|
-
super Origen.file_handler.clean_path_to_sub_template(file), options
|
240
|
-
else
|
241
|
-
collection << Placeholder.new(:render, file, options)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def stats
|
246
|
-
Origen.app.stats
|
247
|
-
end
|
248
|
-
|
249
|
-
def to_be_written?
|
250
|
-
true
|
251
|
-
end
|
252
|
-
|
253
|
-
def set_flow_description(desc)
|
254
|
-
Origen.interface.descriptions.add_for_flow(output_file, desc)
|
255
|
-
end
|
256
|
-
|
257
|
-
def identity_map # :nodoc:
|
258
|
-
Origen.interface.identity_map
|
259
|
-
end
|
260
|
-
|
261
|
-
module ClassMethods
|
262
|
-
def new(*args, &block) # :nodoc:
|
263
|
-
x = allocate
|
264
|
-
x.send(:initialize, *args, &block)
|
265
|
-
Origen.interface.sheet_generators << x
|
266
|
-
x
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|