def test_questionmark(self): self.assertTrue(GlobMatcher('?').matches('a')) self.assertTrue(GlobMatcher('?x?z').matches('axyz')) self.assertTrue(GlobMatcher('a??').matches('abc')) self.assertFalse(GlobMatcher('??').matches('a')) self.assertFalse(GlobMatcher('??').matches('abc')) self.assertFalse(GlobMatcher('a').matches('?'))
def main(context, log_level, target, target_glob, skip_target_glob, repo, out_prefix, clean, dry_run, dry_run_output, enable_flashbundle, no_log_timestamps): # Ensures somewhat pretty logging of what is going on log_fmt = '%(asctime)s %(levelname)-7s %(message)s' if no_log_timestamps: log_fmt = '%(levelname)-7s %(message)s' coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt) if not 'PW_PROJECT_ROOT' in os.environ: raise click.UsageError(""" PW_PROJECT_ROOT not set in the current environment. Please make sure you `source scripts/bootstrap.sh` or `source scripts/activate.sh` before running this script. """.strip()) if dry_run: runner = PrintOnlyRunner(dry_run_output, root=repo) else: runner = ShellRunner(root=repo) if 'all' in target: targets = build.ALL_TARGETS else: requested_targets = set([t.lower for t in target]) targets = [ target for target in build.ALL_TARGETS if target.name.lower in requested_targets] actual_targes = set([t.name.lower for t in targets]) if requested_targets != actual_targes: logging.error('Targets not found: %s', CommaSeparate(actual_targes)) if target_glob: matcher = GlobMatcher(target_glob) targets = [t for t in targets if matcher.matches(t.name)] if skip_target_glob: matcher = GlobMatcher(skip_target_glob) targets = [t for t in targets if not matcher.matches(t.name)] # force consistent sorting targets.sort(key=lambda t: t.name) logging.info('Building targets: %s', CommaSeparate([t.name for t in targets])) context.obj = build.Context( repository_path=repo, output_prefix=out_prefix, runner=runner) context.obj.SetupBuilders( targets=targets, enable_flashbundle=enable_flashbundle) if clean: context.obj.CleanOutputDirectories()
def test_combined(self): self.assertTrue(GlobMatcher('a{,bc}').matches('a')) self.assertTrue(GlobMatcher('a{,bc}').matches('abc')) self.assertTrue(GlobMatcher('ab{c*d,ef}xz').matches('abcdxz')) self.assertTrue(GlobMatcher('ab{c*d,ef}xz').matches('abc1234dxz')) self.assertTrue(GlobMatcher('ab{c*d,ef}xz').matches('abefxz')) self.assertFalse(GlobMatcher('a{,bc}').matches('ab')) self.assertFalse(GlobMatcher('a{,bc}').matches('ax')) self.assertFalse(GlobMatcher('a{,bc}').matches('abcd')) self.assertFalse(GlobMatcher('ab{c*d,ef}xz').matches('abxz')) self.assertFalse(GlobMatcher('ab{c*d,ef}xz').matches('abcxz')) self.assertFalse(GlobMatcher('ab{c*d,ef}xz').matches('abdxz')) self.assertFalse(GlobMatcher('ab{c*d,ef}xz').matches('abxz')) self.assertFalse(GlobMatcher('ab{c*d,ef}xz').matches('abexz')) self.assertFalse(GlobMatcher('ab{c*d,ef}xz').matches('abfxz'))
def test_group(self): self.assertTrue(GlobMatcher('{a,b}').matches('a')) self.assertTrue(GlobMatcher('{a,b}').matches('b')) self.assertTrue(GlobMatcher('some{a,b}here').matches('someahere')) self.assertTrue(GlobMatcher('{a,b}x{c,d}').matches('axd')) self.assertTrue(GlobMatcher('{a,b}x{c,d}').matches('bxc')) self.assertFalse(GlobMatcher('{a,b}').matches('')) self.assertFalse(GlobMatcher('{a,b}').matches('c')) self.assertFalse(GlobMatcher('{a,b}').matches('ac')) self.assertFalse(GlobMatcher('{a,b}').matches('ca')) self.assertFalse(GlobMatcher('{a,b}x{c,d}').matches('axe')) self.assertFalse(GlobMatcher('{a,b}x{c,d}').matches('exd'))
def test_star(self): self.assertTrue(GlobMatcher('*').matches('')) self.assertTrue(GlobMatcher('*').matches('a')) self.assertTrue(GlobMatcher('*').matches('abc')) self.assertTrue(GlobMatcher('*x').matches('abcx')) self.assertTrue(GlobMatcher('*x*').matches('x')) self.assertTrue(GlobMatcher('*x*').matches('xabc')) self.assertTrue(GlobMatcher('*x*').matches('abcx')) self.assertTrue(GlobMatcher('*x*').matches('abcxdef')) self.assertTrue(GlobMatcher('a*c').matches('abc')) self.assertTrue(GlobMatcher('a*c').matches('athisislongc')) self.assertTrue(GlobMatcher('123*').matches('123abc')) self.assertTrue(GlobMatcher('123*').matches('123')) self.assertTrue( GlobMatcher('more*stars*here').matches('more_stars___here')) self.assertFalse(GlobMatcher('*x').matches('abc')) self.assertFalse(GlobMatcher('x*').matches('abc')) self.assertFalse( GlobMatcher('*some*test').matches('thisissomelongertestcase'))
def test_exact_match(self): self.assertTrue(GlobMatcher('').matches('')) self.assertTrue(GlobMatcher('a').matches('a')) self.assertTrue(GlobMatcher('abc').matches('abc')) self.assertFalse(GlobMatcher('').matches('a')) self.assertFalse(GlobMatcher('abc').matches('')) self.assertFalse(GlobMatcher('x').matches('y')) self.assertFalse(GlobMatcher('abcd').matches('abcz')) self.assertFalse(GlobMatcher('abcdef').matches('abczef')) self.assertFalse(GlobMatcher('abc').matches('abcd')) self.assertFalse(GlobMatcher('abc').matches('bc')) self.assertFalse(GlobMatcher('abcd').matches('abc'))