def main(): option_parser = optparse.OptionParser() option_parser.add_option( '--deps', default=None, help='The deps file contains the dependencies path and url') option_parser.add_option( '-v', '--verbose', action='count', default=0, help='Produces additional output for diagnostics. Can be ' 'used up to three times for more logging info.') # pylint: disable=W0612 options, args = option_parser.parse_args() # Following code copied from gclient_utils.py try: # Make stdout auto-flush so buildbot doesn't kill us during lengthy # operations. Python as a strong tendency to buffer sys.stdout. sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) # Make stdout annotated with the thread ids. sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout) except (gclient_utils.Error, subprocess2.CalledProcessError), e: print >> sys.stderr, 'Error: %s' % str(e) return 1
def setUp(self): self.out = gclient_utils.MakeFileAnnotated(io.BytesIO()) self.annotated = gclient_utils.MakeFileAnnotated(io.BytesIO(), include_zero=True)
foo_sol.FuzzyMatchUrl(['https://example.com/foo', 'foo'])) def testFuzzyMatchUrlByName(self): write( '.gclient', 'solutions = [\n' ' { "name": "foo", "url": "https://example.com/foo",\n' ' "deps_file" : ".DEPS.git",\n' ' },\n' ']') write( os.path.join('foo', 'DEPS'), 'deps = {\n' ' "bar": "https://example.com/bar.git@bar_version",\n' '}') options, _ = gclient.OptionParser().parse_args([]) obj = gclient.GClient.LoadCurrentConfig(options) foo_sol = obj.dependencies[0] self.assertEqual('foo', foo_sol.FuzzyMatchUrl(['foo'])) if __name__ == '__main__': sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout) sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr) logging.basicConfig( level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][min(sys.argv.count('-v'), 3)], format='%(relativeCreated)4d %(levelname)5s %(module)13s(' '%(lineno)d) %(message)s') unittest.main()
def disable_buffering(): # Make stdout auto-flush so buildbot doesn't kill us during lengthy # operations. Python as a strong tendency to buffer sys.stdout. sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) # Make stdout annotated with the thread ids. sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout)