Example #1
0
 def test_parse_all_flags(self):
     parser = ArgParser('test_parse_all_flags')
     parser.allow_label(True)
     args, libfuzzer_opts, libfuzzer_args, subprocess_args = parser.parse([
         '--debug',
         '--device',
         'device',
         '--foreground',
         '--monitor',
         '--no-cipd',
         '--output',
         'output',
         '--staging',
         'staging',
         'name',
         'label',
     ])
     self.assertArgsEqual(args,
                          debug=True,
                          device='device',
                          foreground=True,
                          monitor=True,
                          no_cipd=True,
                          output='output',
                          staging='staging',
                          name='name',
                          label='label')
     self.assertEqual(libfuzzer_opts, {})
     self.assertEqual(libfuzzer_args, [])
     self.assertEqual(subprocess_args, [])
Example #2
0
    def test_parse_args_unrecognized(self):
        parser = ArgParser('test_parse_args_unrecognized')
        parser.require_name(False)

        with self.assertRaises(SystemExit):
            parser.parse_args(['--unknown'])

        with self.assertRaises(SystemExit):
            parser.parse_args(['-help=1'])

        parser.require_name(True)
        parser.allow_label(True)
        with self.assertRaises(SystemExit):
            parser.parse_args(['one', 'two', 'three'])
Example #3
0
    def test_parse_args_label(self):
        parser = ArgParser('test_parse_args_label')

        # Error if label present when not allowed.
        with self.assertRaises(SystemExit):
            parser.parse_args(['name', 'label'])

        # label not allowed if name is optional.
        parser.require_name(False)
        with self.assertRaises(AssertionError):
            parser.allow_label(True)

        parser.require_name(True)
        parser.allow_label(True)
        args = parser.parse_args(['name', 'label'])
        self.assertArgsEqual(args, name='name', label='label')