Python2+3: build_travis.py and Travis tests

pull/5848/head
Jimmy Brisson 2018-01-12 17:54:18 -06:00
parent 424ad856a9
commit db4c380b2b
4 changed files with 29 additions and 15 deletions

View File

@ -10,7 +10,7 @@ env:
--data @- << DATA\n{
"state": "$0",
"description": "$1",
"context": "travis-ci/$NAME",
"context": "travis-ci/$NAME/$(python --version)",
"target_url": "https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID"
}\nDATA'
@ -73,6 +73,10 @@ matrix:
- env:
- NAME=tools
python:
- '2.7'
- '3.5'
- '3.6'
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded
@ -175,7 +179,7 @@ matrix:
- mkdir BUILD
script:
# Run local mbed 2 testing
- python2 -u tools/build_travis.py --vendor "${NAME#mbed2-}"
- python -u tools/build_travis.py --vendor "${NAME#mbed2-}"
- <<: *mbed-2
env: NAME=mbed2-STM
- <<: *mbed-2
@ -190,3 +194,8 @@ matrix:
env: NAME=mbed2-NUVOTON
- <<: *mbed-2
env: NAME=mbed2-RENESAS
# Change python version here only because 3x the other jobs does not add any more coverage
python:
- '2.7'
- '3.5'
- '3.6'

View File

@ -17,6 +17,8 @@ limitations under the License.
LIBRARIES BUILD
"""
from __future__ import print_function, division, absolute_import
import sys
from time import time
from os.path import join, abspath, dirname
@ -130,7 +132,7 @@ if __name__ == '__main__':
# Only prints matrix of supported toolchains
if options.supported_toolchains:
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex))
exit(0)
@ -184,7 +186,7 @@ if __name__ == '__main__':
tt_id = "%s::%s" % (toolchain, target)
if toolchain not in TARGET_MAP[target].supported_toolchains:
# Log this later
print "%s skipped: toolchain not supported" % tt_id
print("%s skipped: toolchain not supported" % tt_id)
skipped.append(tt_id)
else:
try:
@ -224,26 +226,24 @@ if __name__ == '__main__':
successes.append(tt_id)
else:
skipped.append(tt_id)
except Exception, e:
except Exception as e:
if options.verbose:
import traceback
traceback.print_exc(file=sys.stdout)
sys.exit(1)
failures.append(tt_id)
print e
print(e)
# Write summary of the builds
print
print "Completed in: (%.2f)s" % (time() - start)
print
print("\nCompleted in: (%.2f)s\n" % (time() - start))
for report, report_name in [(successes, "Build successes:"),
(skipped, "Build skipped:"),
(failures, "Build failures:"),
]:
if report:
print print_build_results(report, report_name),
print(print_build_results(report, report_name))
if failures:
sys.exit(1)

View File

@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import print_function, division, absolute_import
import os
import sys
@ -382,11 +383,12 @@ def run_builds(dry_run, vendor):
toolchain_list = build["toolchains"]
if type(toolchain_list) != type([]): toolchain_list = [toolchain_list]
for toolchain in toolchain_list:
cmdline = "python tools/build.py -m %s -t %s -c --silent "% (build["target"], toolchain)
cmdline = ("%s tools/build.py -m %s -t %s -c --silent "%
(sys.executable, build["target"], toolchain))
libs = build.get("libs", [])
if libs:
cmdline = cmdline + " ".join(["--" + l for l in libs])
print "Executing: " + cmdline
print("Executing: %s" % cmdline)
if not dry_run:
if os.system(cmdline) != 0:
sys.exit(1)
@ -408,8 +410,11 @@ def run_test_linking(dry_run, vendor):
for test_lib in tests:
test_names = tests[test_lib]
test_lib_switch = "--" + test_lib if test_lib else ""
cmdline = "python tools/make.py -m %s -t %s -c --silent %s -n %s " % (link["target"], toolchain, test_lib_switch, ",".join(test_names))
print "Executing: " + cmdline
cmdline = ("%s tools/make.py -m %s -t %s -c --silent %s "
"-n %s" % (sys.executable, link["target"],
toolchain, test_lib_switch,
",".join(test_names)))
print("Executing: %s" % cmdline)
if not dry_run:
if os.system(cmdline) != 0:
sys.exit(1)

View File

@ -865,7 +865,7 @@ class mbedToolchain:
# ARM, GCC, IAR cross compatible
def get_arch_file(self, objects):
archive_file = join(self.build_dir, ".archive_files.txt")
with open(archive_file, "wb") as f:
with open(archive_file, "w") as f:
o_list = []
for o in objects:
o_list.append('"%s"' % o)