Пример #1
0
    def __init__(self,
                 script=None,
                 sources=None,
                 address=None,
                 payload=None,
                 **kwargs):
        if sources is not None:
            raise TargetDefinitionException(
                self, "sources must be None: was {!r}.".format(sources))
        elif script and script.endswith(self.script_file_ext):
            script_relpath_buildroot = os.path.join(address.spec_path, script)
            base_globs = BaseGlobs.from_sources_field(
                [script_relpath_buildroot], address.spec_path)
            fileset_with_spec = LazyFilesetWithSpec(address.spec_path,
                                                    base_globs.filespecs,
                                                    lambda: [script])
        else:
            raise TargetDefinitionException(
                self, "script argument '{}' to {}() must end in '{}'.".format(
                    script, self.alias(), self.script_file_ext))

        payload = payload or Payload()
        payload.add_fields({
            'sources': SourcesField(fileset_with_spec, address),
        })
        super(Perl6Binary, self).__init__(address=address,
                                          payload=payload,
                                          **kwargs)
Пример #2
0
  def test_passes_lazy_fileset_with_spec_through(self):
    self.create_file('foo/a.txt', 'a_contents')

    fileset = LazyFilesetWithSpec('foo', {'globs':['foo/a.txt']}, lambda: ['foo/a.txt'])
    sf = SourcesField(sources=fileset)

    self.assertIs(fileset, sf.sources)
    self.assertEqual(['foo/a.txt'], list(sf.source_paths))
Пример #3
0
 def test_lazy_fileset_with_spec_fails_if_exclude_filespec_not_prefixed_by_relroot(
         self):
     with self.assertRaises(ValueError):
         LazyFilesetWithSpec('foo', {
             'globs': [],
             'exclude': [{
                 'globs': ['notfoo/a.txt']
             }]
         }, lambda: ['foo/a.txt'])
Пример #4
0
    def test_passes_lazy_fileset_with_spec_through(self) -> None:
        self.create_file("foo/a.txt", "a_contents")

        fileset = LazyFilesetWithSpec("foo", {"globs": ["foo/a.txt"]},
                                      lambda: ["foo/a.txt"])
        sf = SourcesField(sources=fileset)

        self.assertIs(fileset, sf.sources)
        self.assertEqual(["foo/a.txt"], list(sf.source_paths))
Пример #5
0
 def test_lazy_fileset_with_spec_fails_if_exclude_filespec_not_prefixed_by_relroot(
         self) -> None:
     with self.assertRaises(ValueError):
         LazyFilesetWithSpec(
             "foo",
             {
                 "globs": [],
                 "exclude": [{
                     "globs": ["notfoo/a.txt"]
                 }]
             },
             lambda: ["foo/a.txt"],
         )