Skip to content

Commit

Permalink
Merge pull request #471 from dbhi/feat-overwrite
Browse files Browse the repository at this point in the history
Add option 'overwrite' to set_sim_option
  • Loading branch information
kraigher authored Apr 13, 2019
2 parents faa839a + b08a018 commit 5ea1338
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
7 changes: 6 additions & 1 deletion vunit/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,18 @@ def set_generic(self, name, value):
for config in configs.values():
config.set_generic(name, value)

def set_sim_option(self, name, value):
def set_sim_option(self, name, value, overwrite=True):
"""
Set sim option
:param overwrite: To overwrite the option or append to the existing value
"""
self._check_enabled()
for configs in self.get_configuration_dicts():
for config in configs.values():
if not overwrite:
config.set_sim_option(name, config.sim_options.get(name, []) + value)
continue
config.set_sim_option(name, value)

def set_pre_config(self, value):
Expand Down
22 changes: 13 additions & 9 deletions vunit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,14 @@ def set_parameter(self, name, value, allow_empty=False):
for test_bench in check_not_empty(test_benches, allow_empty, "No test benches found"):
test_bench.set_generic(name, value)

def set_sim_option(self, name, value, allow_empty=False):
def set_sim_option(self, name, value, allow_empty=False, overwrite=True):
"""
Set simulation option in all |configurations|
:param name: |simulation_options|
:param value: The value of the simulation option
:param allow_empty: To disable an error when no test benches were found
:param overwrite: To overwrite the option or append to the existing value
:example:
Expand All @@ -583,7 +584,7 @@ def set_sim_option(self, name, value, allow_empty=False):
"""
test_benches = self._test_bench_list.get_test_benches()
for test_bench in check_not_empty(test_benches, allow_empty, "No test benches found"):
test_bench.set_sim_option(name, value)
test_bench.set_sim_option(name, value, overwrite)

def set_compile_option(self, name, value, allow_empty=False):
"""
Expand Down Expand Up @@ -1194,13 +1195,14 @@ def set_parameter(self, name, value, allow_empty=False):
for test_bench in self.get_test_benches(allow_empty=allow_empty):
test_bench.set_generic(name, value)

def set_sim_option(self, name, value, allow_empty=False):
def set_sim_option(self, name, value, allow_empty=False, overwrite=True):
"""
Set simlation option within all |configurations| of test benches and tests this library
Set simulation option within all |configurations| of test benches and tests this library
:param name: |simulation_options|
:param value: The value of the simulation option
:param allow_empty: To disable an error when no test benches were found
:param overwrite: To overwrite the option or append to the existing value
:example:
Expand All @@ -1212,7 +1214,7 @@ def set_sim_option(self, name, value, allow_empty=False):
Only affects test benches added *before* the option is set.
"""
for test_bench in self.get_test_benches(allow_empty=allow_empty):
test_bench.set_sim_option(name, value)
test_bench.set_sim_option(name, value, overwrite)

def set_compile_option(self, name, value, allow_empty=False):
"""
Expand Down Expand Up @@ -1506,12 +1508,13 @@ def set_parameter(self, name, value):
"""
self._test_bench.set_generic(name, value)

def set_sim_option(self, name, value):
def set_sim_option(self, name, value, overwrite=True):
"""
Set simulation option within all |configurations| of this test bench or test cases within it
:param name: |simulation_options|
:param value: The value of the simulation option
:param overwrite: To overwrite the option or append to the existing value
:example:
Expand All @@ -1520,7 +1523,7 @@ def set_sim_option(self, name, value):
test_bench.set_sim_option("ghdl.flags", ["--no-vital-checks"])
"""
self._test_bench.set_sim_option(name, value)
self._test_bench.set_sim_option(name, value, overwrite)

def set_pre_config(self, value):
"""
Expand Down Expand Up @@ -1786,12 +1789,13 @@ def set_parameter(self, name, value):
"""
self._test_case.set_generic(name, value)

def set_sim_option(self, name, value):
def set_sim_option(self, name, value, overwrite=True):
"""
Set simulation option within all |configurations| of this test
:param name: |simulation_options|
:param value: The value of the simulation option
:param overwrite: To overwrite the option or append to the existing value
:example:
Expand All @@ -1800,7 +1804,7 @@ def set_sim_option(self, name, value):
test.set_sim_option("ghdl.flags", ["--no-vital-checks"])
"""
self._test_case.set_sim_option(name, value)
self._test_case.set_sim_option(name, value, overwrite)

def set_pre_config(self, value):
"""
Expand Down

0 comments on commit 5ea1338

Please sign in to comment.