예제 #1
0
    def test_verify_deps(self):
        root_build_dir = os.getcwd()
        cts_file = 'test.this_is_cts'
        invoker_label = "//sdk/cts/build:verify_cts_deps_test"

        deps = ['//zircon/public/lib/zxtest:zxtest']
        cts_element = VerifyCtsDeps(root_build_dir, cts_file, invoker_label,
                                    deps)
        self.assertListEqual(cts_element.verify_deps(), [])

        deps = ['//this/dep/isnt/allowed/in:cts']
        cts_element = VerifyCtsDeps(root_build_dir, cts_file, invoker_label,
                                    deps)
        self.assertListEqual(cts_element.verify_deps(), deps)

        deps = [
            '//this/dep/isnt/allowed/in:cts', '//this/dep/isnt/allowed/in:cts2'
        ]
        cts_element = VerifyCtsDeps(root_build_dir, cts_file, invoker_label,
                                    deps)
        self.assertListEqual(cts_element.verify_deps(), deps)
예제 #2
0
    def test_verify_deps(self):
        cts_file = 'test.this_is_cts'
        invoker_label = "//sdk/cts/build:verify_cts_deps_test"
        allowed_cts_deps = ['//zircon/system/ulib/zxtest:zxtest']
        allowed_cts_dirs = ['//sdk/*']

        with TemporaryDirectory() as root_build_dir:
            sdk_manifests = [
                self.create_empty_sdk_manifest(root_build_dir, "core")
            ]
            cts_element = VerifyCtsDeps(
                root_build_dir, cts_file, invoker_label, allowed_cts_deps,
                allowed_cts_deps, allowed_cts_dirs, sdk_manifests)
            self.assertListEqual(cts_element.verify_deps(), [])

            deps = ['//this/dep/isnt/allowed/in:cts']
            cts_element = VerifyCtsDeps(
                root_build_dir, cts_file, invoker_label, deps, allowed_cts_deps,
                allowed_cts_dirs, sdk_manifests)
            self.assertListEqual(cts_element.verify_deps(), deps)

            deps = [
                '//this/dep/isnt/allowed/in:cts',
                '//this/dep/isnt/allowed/in:cts2',
            ]
            cts_element = VerifyCtsDeps(
                root_build_dir, cts_file, invoker_label, deps, allowed_cts_deps,
                allowed_cts_dirs, sdk_manifests)
            self.assertListEqual(cts_element.verify_deps(), deps)

            deps = ['//sdk/this/is/a/real:target']
            cts_element = VerifyCtsDeps(
                root_build_dir, cts_file, invoker_label, deps, allowed_cts_deps,
                allowed_cts_dirs, sdk_manifests)
            self.assertListEqual(cts_element.verify_deps(), [])

            deps = [
                '//sdk/this/is/a/real:target',
                '//zircon/system/ulib/zxtest:zxtest',
            ]
            cts_element = VerifyCtsDeps(
                root_build_dir, cts_file, invoker_label, deps, allowed_cts_deps,
                allowed_cts_dirs, sdk_manifests)
            self.assertListEqual(cts_element.verify_deps(), [])

            deps = [
                '//sdk/lib/fdio:fdio',
                '//third_party/dart-pkg/pub/some-dart-pkg',
                '//zircon/system/ulib/zxtest:zxtest',
            ]
            manifest = {
                "atoms":
                    [
                        {
                            "category":
                                "partner",
                            "deps": [],
                            "files": [],
                            "gn-label":
                                "//sdk/lib/fdio:fdio_sdk_manifest(//build/toolchain/fuchsia:x64)",
                            "id":
                                "sdk://pkg/fdio",
                            "meta":
                                "pkg/fdio/meta.json",
                            "type":
                                "cc_prebuilt_library"
                        }
                    ],
                "ids": []
            }
            with open(sdk_manifests[0], 'w') as sdk_manifest:
                json.dump(manifest, sdk_manifest)
            allowed_cts_dirs = ['//third_party/dart-pkg/pub/*']
            cts_element = VerifyCtsDeps(
                root_build_dir, cts_file, invoker_label, deps, allowed_cts_deps,
                allowed_cts_dirs, sdk_manifests)
            self.assertListEqual(cts_element.verify_deps(), [])