def test_add_source_file_vhdl_standard_is_used(self): file_name = "foo.vhd" self.create_file(file_name) for method in range(4): with set_env(VUNIT_VHDL_STANDARD="93"): ui = self._create_ui() lib = ui.add_library("lib", vhdl_standard="2002") if method == 0: source_file = lib.add_source_file(file_name, vhdl_standard="2008") elif method == 1: source_file = lib.add_source_files(file_name, vhdl_standard="2008")[0] elif method == 2: source_file = ui.add_source_file(file_name, "lib", vhdl_standard="2008") elif method == 3: source_file = ui.add_source_files(file_name, "lib", vhdl_standard="2008")[0] self.assertEqual(source_file.vhdl_standard, "2008")
def test_simulate_without_simulator_fails(self, logger): with set_env(): ui = self._create_ui_real_sim() self._run_main(ui, 1) self.assertEqual(len(logger.error.mock_calls), 1) self.assertTrue("No available simulator detected" in str( logger.error.mock_calls))
def test_default_vhdl_standard_is_used(self): file_name = "foo.vhd" self.create_file(file_name) with set_env(VUNIT_VHDL_STANDARD="93"): ui = self._create_ui() lib = ui.add_library("lib") source_file = lib.add_source_file(file_name) self.assertEqual(source_file.vhdl_standard, "93")
def test_copies_modelsim_ini_file_from_user(self): (modelsim_ini, installed_modelsim_ini, user_modelsim_ini) = self._get_inis() with open(installed_modelsim_ini, "w") as fptr: fptr.write("installed") with open(user_modelsim_ini, "w") as fptr: fptr.write("user") with set_env(VUNIT_MODELSIM_INI=user_modelsim_ini): ModelSimInterface(prefix=self.prefix_path, output_path=self.output_path, persistent=False) with open(modelsim_ini, "r") as fptr: self.assertEqual(fptr.read(), "user")
def test_overwrites_modelsim_ini_file_from_user(self): modelsim_ini = join(self.output_path, "modelsim.ini") installed_modelsim_ini = join(self.prefix_path, "..", "modelsim.ini") user_modelsim_ini = join(self.test_path, "my_modelsim.ini") with open(modelsim_ini, "w") as fptr: fptr.write("existing") with open(installed_modelsim_ini, "w") as fptr: fptr.write("installed") with open(user_modelsim_ini, "w") as fptr: fptr.write("user") with set_env(VUNIT_MODELSIM_INI=user_modelsim_ini): ModelSimInterface(prefix=self.prefix_path, output_path=self.output_path, persistent=False) with open(modelsim_ini, "r") as fptr: self.assertEqual(fptr.read(), "user")
def test_can_list_files_without_simulator(self): with set_env(): ui = self._create_ui_real_sim("--files") self._run_main(ui, 0)