Skip to content

Commit de1759c

Browse files
author
Ross Bayer
committed
[Build System: build-script] Added a new run_test.py script to utils/swift_build_support which is used to run the unit test suite.
1 parent 7587c7c commit de1759c

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

Diff for: utils/swift_build_support/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ structures used by the Swift build script.
66
You may run unit tests for `swift_build_support` from the command line:
77

88
```sh
9-
apple/swift $ python -m unittest discover -s utils/swift_build_support
9+
$ python utils/swift_build_support/run_tests.py
1010
```

Diff for: utils/swift_build_support/run_tests.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
11+
12+
"""
13+
Small script used to easily run the swift_build_support module unit tests.
14+
"""
15+
16+
17+
from __future__ import absolute_import, unicode_literals
18+
19+
import os
20+
import sys
21+
import unittest
22+
23+
24+
MODULE_DIR = os.path.abspath(os.path.dirname(__file__))
25+
UTILS_DIR = os.path.abspath(os.path.join(MODULE_DIR, os.pardir))
26+
27+
28+
if __name__ == '__main__':
29+
# Add the swift/utils directory to the Python path.
30+
sys.path.append(UTILS_DIR)
31+
32+
# Discover all tests for the module.
33+
module_tests = unittest.defaultTestLoader.discover(MODULE_DIR)
34+
35+
# Create and run test suite.
36+
suite = unittest.TestSuite()
37+
suite.addTests(module_tests)
38+
39+
runner = unittest.TextTestRunner()
40+
result = runner.run(suite)
41+
42+
sys.exit(not result.wasSuccessful())

Diff for: utils/swift_build_support/test_swift_build_support.sh

-12
This file was deleted.

Diff for: validation-test/Python/swift_build_support.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
// UNSUPPORTED: OS=tvos
88
// UNSUPPORTED: OS=watchos
99

10-
// RUN: env PYTHONPATH=%utils:$PYTHONPATH %{python} -m unittest discover -s %utils/swift_build_support
10+
// RUN: %{python} %utils/swift_build_support/run_tests.py

0 commit comments

Comments
 (0)