| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import glob | 7 import glob |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import shutil | 11 import shutil |
| 12 import subprocess | 12 import subprocess |
| 13 import sys | 13 import sys |
| 14 import tempfile | 14 import tempfile |
| 15 import gsutil | 15 import gsutil |
| 16 import ziputils | 16 import ziputils |
| 17 import hashlib | 17 import hashlib |
| 18 | 18 |
| 19 from os.path import join | 19 from os.path import join |
| 20 from xml.dom.minidom import parseString |
| 20 | 21 |
| 21 BUILD_OS = None | 22 BUILD_OS = None |
| 22 DART_PATH = None | 23 DART_PATH = None |
| 23 TOOLS_PATH = None | 24 TOOLS_PATH = None |
| 24 | 25 |
| 25 GSU_PATH_REV = None | 26 GSU_PATH_REV = None |
| 26 GSU_PATH_LATEST = None | 27 GSU_PATH_LATEST = None |
| 27 GSU_API_DOCS_PATH = None | 28 GSU_API_DOCS_PATH = None |
| 28 GSU_API_DOCS_BUCKET = 'gs://dartlang-api-docs' | 29 GSU_API_DOCS_BUCKET = 'gs://dartlang-api-docs' |
| 29 | 30 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if status: | 396 if status: |
| 396 return status | 397 return status |
| 397 | 398 |
| 398 if not build_skip_tests: | 399 if not build_skip_tests: |
| 399 PrintSeparator('Running the tests') | 400 PrintSeparator('Running the tests') |
| 400 junit_status = ant.RunAnt('../com.google.dart.tools.tests.feature_releng', | 401 junit_status = ant.RunAnt('../com.google.dart.tools.tests.feature_releng', |
| 401 'buildTests.xml', | 402 'buildTests.xml', |
| 402 revision, options.name, buildroot, buildout, | 403 revision, options.name, buildroot, buildout, |
| 403 editorpath, buildos, | 404 editorpath, buildos, |
| 404 extra_artifacts=extra_artifacts) | 405 extra_artifacts=extra_artifacts) |
| 406 |
| 407 #<testsuite errors="0" failures="1" name="com.google.dart.tools.core_test" |
| 408 # tests="740" time="40.713"> |
| 409 testResults = parseString(open(join(buildout, 'test-results.xml')).read()) |
| 410 testsuite = testResults.documentElement |
| 411 |
| 412 if testsuite.getAttribute("errors") != "0": |
| 413 junit_status = 1 |
| 414 if testsuite.getAttribute("failures") != "0": |
| 415 junit_status = 1 |
| 416 |
| 417 print "\n%s: %s tests, %s errors, %s failures (time: %s)\n" % ( |
| 418 testsuite.getAttribute("name"), |
| 419 testsuite.getAttribute("tests"), |
| 420 testsuite.getAttribute("errors"), |
| 421 testsuite.getAttribute("failures"), |
| 422 testsuite.getAttribute("time")) |
| 423 |
| 405 properties = ReadPropertyFile(buildos, ant_property_file.name) | 424 properties = ReadPropertyFile(buildos, ant_property_file.name) |
| 406 if buildos: | |
| 407 UploadTestHtml(buildout, to_bucket, revision, buildos, gsu) | |
| 408 if junit_status: | 425 if junit_status: |
| 409 if properties['build.runtime']: | 426 if properties['build.runtime']: |
| 410 #if there is a build.runtime and the status is not | 427 #if there is a build.runtime and the status is not |
| 411 #zero see if there are any *.log entries | 428 #zero see if there are any *.log entries |
| 412 PrintErrorLog(properties['build.runtime']) | 429 PrintErrorLog(properties['build.runtime']) |
| 413 else: | 430 else: |
| 414 junit_status = 0 | 431 junit_status = 0 |
| 415 | 432 |
| 416 if buildos: | 433 if buildos: |
| 417 _InstallArtifacts(buildout, buildos, extra_artifacts) | 434 _InstallArtifacts(buildout, buildos, extra_artifacts) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if os.path.exists(configdir): | 505 if os.path.exists(configdir): |
| 489 for logfile in glob.glob(os.path.join(configdir, '*.log')): | 506 for logfile in glob.glob(os.path.join(configdir, '*.log')): |
| 490 print 'Found log file: ' + logfile | 507 print 'Found log file: ' + logfile |
| 491 found = True | 508 found = True |
| 492 for logline in open(logfile): | 509 for logline in open(logfile): |
| 493 print logline | 510 print logline |
| 494 if not found: | 511 if not found: |
| 495 print 'no log file was found in ' + configdir | 512 print 'no log file was found in ' + configdir |
| 496 | 513 |
| 497 | 514 |
| 498 def UploadTestHtml(buildout, bucket, svnid, buildos, gsu): | |
| 499 """Upload the Test Results HTML to GoogleStorage. | |
| 500 | |
| 501 Args: | |
| 502 buildout: the location ofthe output of the build | |
| 503 bucket: the Google Storage bucket the code is staged in | |
| 504 svnid: the revision id for this build | |
| 505 buildos: the os the build is running on | |
| 506 gsu: the gsutil object | |
| 507 """ | |
| 508 print 'UploadTestHtml(%s, %s, %s, %s)' % (buildout, bucket, svnid, buildos) | |
| 509 local_dir = '{0}'.format(svnid) | |
| 510 html_dir = os.path.join(buildout, 'html') | |
| 511 cwd = os.getcwd() | |
| 512 gs_test_dir_name = 'tests' | |
| 513 tmp_dir = None | |
| 514 try: | |
| 515 if os.path.exists(html_dir): | |
| 516 tmp_dir = tempfile.mkdtemp(prefix=gs_test_dir_name) | |
| 517 local_path = os.path.join(tmp_dir, local_dir) | |
| 518 os.makedirs(local_path) | |
| 519 os.chdir(tmp_dir) | |
| 520 shutil.copytree(html_dir, os.path.join(local_path, gs_test_dir_name, | |
| 521 buildos)) | |
| 522 gsu.Copy(svnid, bucket, recursive_flag=True) | |
| 523 finally: | |
| 524 os.chdir(cwd) | |
| 525 if tmp_dir is not None and os.path.exists(tmp_dir): | |
| 526 shutil.rmtree(tmp_dir, ignore_errors=True) | |
| 527 | |
| 528 | |
| 529 def _FindRcpZipFiles(out_dir): | 515 def _FindRcpZipFiles(out_dir): |
| 530 """Find the Zipped RCP files. | 516 """Find the Zipped RCP files. |
| 531 | 517 |
| 532 Args: | 518 Args: |
| 533 out_dir: the directory the files will be located in | 519 out_dir: the directory the files will be located in |
| 534 | 520 |
| 535 Returns: | 521 Returns: |
| 536 a collection of rcp zip files | 522 a collection of rcp zip files |
| 537 """ | 523 """ |
| 538 out_dir = os.path.normpath(os.path.normcase(out_dir)) | 524 out_dir = os.path.normpath(os.path.normcase(out_dir)) |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 """delete the given file - do not re-throw any exceptions that occur""" | 1042 """delete the given file - do not re-throw any exceptions that occur""" |
| 1057 if os.path.exists(f): | 1043 if os.path.exists(f): |
| 1058 try: | 1044 try: |
| 1059 os.remove(f) | 1045 os.remove(f) |
| 1060 except OSError: | 1046 except OSError: |
| 1061 print 'error deleting %s' % f | 1047 print 'error deleting %s' % f |
| 1062 | 1048 |
| 1063 | 1049 |
| 1064 if __name__ == '__main__': | 1050 if __name__ == '__main__': |
| 1065 sys.exit(main()) | 1051 sys.exit(main()) |
| OLD | NEW |