blob: 6680632a674fe6be4841052e3a0c39a5418ee222 [file] [log] [blame]
# swift/test/ - SwiftTest format for lit tests -*- python -*-
# This source file is part of the open source project
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
# See for license information
# See for the list of Swift project authors
# -----------------------------------------------------------------------------
# This is a test format file for the 'lit' test runner.
# -----------------------------------------------------------------------------
import os
import lit
import lit.formats
import lit.util
class SwiftTest(lit.formats.ShTest, object):
def __init__(self, coverage_mode=None, execute_external=True):
super(SwiftTest, self).__init__(execute_external=execute_external)
if coverage_mode == "FALSE":
self.coverage_mode = None
self.coverage_mode = coverage_mode
self.skipped_tests = set()
def before_test(self, test, litConfig):
if self.coverage_mode:
# FIXME: The compiler crashers run so fast they fill up the
# merger's queue (and therefore the build bot's disk)
if 'crasher' in test.getSourcePath():
test.config.environment["LLVM_PROFILE_FILE"] = os.devnull
if self.coverage_mode == "NOT_MERGED":
execpath = test.getExecPath()
profdir = os.path.join(os.path.dirname(execpath), "Output",
os.path.basename(execpath) + '.profdir')
if not os.path.exists(profdir):
test.config.environment["LLVM_PROFILE_FILE"] = \
os.path.join(profdir, "swift-%p.profraw")
test.config.environment["LLVM_PROFILE_FILE"] = \
def after_test(self, test, litConfig, result):
if test.getSourcePath() in self.skipped_tests:
return result
def execute(self, test, litConfig):
self.before_test(test, litConfig)
result = super(SwiftTest, self).execute(test, litConfig)
return self.after_test(test, litConfig, result)