Exemplo n.º 1
0
 def setup(ui):
     " Setup the project "
     lib = ui.add_library("lib")
     file_name = join(tempdir, "tb_filter.vhd")
     create_vhdl_test_bench_file("tb_filter", file_name,
                                 tests=["Test 1", "Test 2", "Test 3"],
                                 test_attributes={
                                     "Test 1": [".attr0"],
                                     "Test 2": [".attr0", ".attr1"],
                                     "Test 3": [".attr1"]
                                 })
     lib.add_source_file(file_name)
Exemplo n.º 2
0
 def setup(ui):
     " Setup the project "
     lib = ui.add_library("lib")
     file_name = join(tempdir, "tb_filter.vhd")
     create_vhdl_test_bench_file("tb_filter",
                                 file_name,
                                 tests=["Test 1", "Test 2", "Test 3"],
                                 test_attributes={
                                     "Test 1": [".attr0"],
                                     "Test 2": [".attr0", ".attr1"],
                                     "Test 3": [".attr1"]
                                 })
     lib.add_source_file(file_name)
Exemplo n.º 3
0
    def test_export_json(self, tempdir):
        json_file = join(tempdir, "export.json")

        ui = self._create_ui("--export-json", json_file)
        lib1 = ui.add_library("lib1")
        lib2 = ui.add_library("lib2")

        file_name1 = join(tempdir, "tb_foo.vhd")
        create_vhdl_test_bench_file("tb_foo", file_name1)
        lib1.add_source_file(file_name1)

        file_name2 = join(tempdir, "tb_bar.vhd")
        create_vhdl_test_bench_file("tb_bar", file_name2,
                                    tests=["Test one", "Test two"],
                                    test_attributes={"Test one": [".attr0"]})
        lib2.add_source_file(file_name2)
        lib2.test_bench("tb_bar").set_attribute(".attr1", "bar")

        self._run_main(ui)

        with open(json_file, "r") as fptr:
            data = json.load(fptr)

        # Check known keys
        self.assertEqual(set(data.keys()),
                         set(["export_format_version",
                              "files",
                              "tests"]))

        # Check that export format is semantic version with integer values
        self.assertEqual(set(data["export_format_version"].keys()),
                         set(("major", "minor", "patch")))
        assert all(isinstance(value, int)
                   for value in data["export_format_version"].values())

        # Check the contents of the files section
        self.assertEqual(set((item["library_name"], item["file_name"])
                             for item in data["files"]),
                         set([("lib1", abspath(file_name1)),
                              ("lib2", abspath(file_name2))]))

        # Check the contents of the tests section
        self.assertEqual({item["name"]: (item["location"], item["attributes"]) for item in data["tests"]},
                         {"lib1.tb_foo.all": ({"file_name": file_name1, "offset": 180, "length": 18},
                                              {}),
                          "lib2.tb_bar.Test one": ({"file_name": file_name2, "offset": 235, "length": 8},
                                                   {".attr0": None, ".attr1": "bar"}),
                          "lib2.tb_bar.Test two": ({"file_name": file_name2, "offset": 283, "length": 8},
                                                   {".attr1": "bar"})})