Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option 'overwrite' to set_sim_option #471

Merged
merged 1 commit into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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