Skip to content

Commit 5a870df

Browse files
committed
[Tests] Replace %{built_tests_dir} with %T
When I first added functional tests in 589b23d, I struggled against `lit`'s design: I attempted to prevent test output from being generated alongside the tests themselves. It wasn't until 8181c16 that I saw the error of my ways: `lit` places test output in the next to the tests in order to make them easier to debug. That commit embraced this design, and excluded the test output from source control. However, we can do better. The XCTest `lit` tests produce test executables, which the test suite currently attempts to hide in a tmpdir somewhere. These executables are useful: it's nice to be able to re-run an executable at will. Change the location of the where the executables are generated. Instead of placing them in `%{built_tests_dir}`, place them in an output directory next to the test itself (a concept built into `lit` and provided by the `%T` substitution). Since we no longer use `%{built_tests_dir}`, remove it.
1 parent 5bd36b5 commit 5a870df

File tree

20 files changed

+42
-47
lines changed

20 files changed

+42
-47
lines changed

Tests/Functional/Asynchronous/Expectations/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Asynchronous
2-
// RUN: %{built_tests_dir}/Asynchronous > %t || true
1+
// RUN: %{swiftc} %s -o %T/Asynchronous
2+
// RUN: %T/Asynchronous > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Asynchronous/Handler/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Handler
2-
// RUN: %{built_tests_dir}/Handler > %t || true
1+
// RUN: %{swiftc} %s -o %T/Handler
2+
// RUN: %T/Handler > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Asynchronous/Misuse/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Misuse
2-
// RUN: %{built_tests_dir}/Misuse > %t || true
1+
// RUN: %{swiftc} %s -o %T/Misuse
2+
// RUN: %T/Misuse > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Asynchronous/Notifications/Expectations/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Asynchronous-Notifications
2-
// RUN: %{built_tests_dir}/Asynchronous-Notifications > %t || true
1+
// RUN: %{swiftc} %s -o %T/Asynchronous-Notifications
2+
// RUN: %T/Asynchronous-Notifications > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Asynchronous/Notifications/Handler/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Asynchronous-Notifications-Handler
2-
// RUN: %{built_tests_dir}/Asynchronous-Notifications-Handler > %t || true
1+
// RUN: %{swiftc} %s -o %T/Asynchronous-Notifications-Handler
2+
// RUN: %T/Asynchronous-Notifications-Handler > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Asynchronous/Predicates/Expectations/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Asynchronous-Predicates
2-
// RUN: %{built_tests_dir}/Asynchronous-Predicates > %t || true
1+
// RUN: %{swiftc} %s -o %T/Asynchronous-Predicates
2+
// RUN: %T/Asynchronous-Predicates > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Asynchronous/Predicates/Handler/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Asynchronous-Predicates-Handler
2-
// RUN: %{built_tests_dir}/Asynchronous-Predicates-Handler > %t || true
1+
// RUN: %{swiftc} %s -o %T/Asynchronous-Predicates-Handler
2+
// RUN: %T/Asynchronous-Predicates-Handler > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/ErrorHandling/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/ErrorHandling
2-
// RUN: %{built_tests_dir}/ErrorHandling > %t || true
1+
// RUN: %{swiftc} %s -o %T/ErrorHandling
2+
// RUN: %T/ErrorHandling > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/FailingTestSuite/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/FailingTestSuite
2-
// RUN: %{built_tests_dir}/FailingTestSuite > %t || true
1+
// RUN: %{swiftc} %s -o %T/FailingTestSuite
2+
// RUN: %T/FailingTestSuite > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/FailureMessagesTestCase/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/FailureMessagesTestCase
2-
// RUN: %{built_tests_dir}/FailureMessagesTestCase > %t || true
1+
// RUN: %{swiftc} %s -o %T/FailureMessagesTestCase
2+
// RUN: %T/FailureMessagesTestCase > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/ListTests/main.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/ListTests
2-
// RUN: %{built_tests_dir}/ListTests --list-tests > %t_list || true
1+
// RUN: %{swiftc} %s -o %T/ListTests
2+
// RUN: %T/ListTests --list-tests > %t_list || true
33
// RUN: %{xctest_checker} %t_list %s
4-
// RUN: %{built_tests_dir}/ListTests --dump-tests-json > %t_json || true
5-
// RUN: %{built_tests_dir}/ListTests --verify %t_json > %t_verify
4+
// RUN: %T/ListTests --dump-tests-json > %t_json || true
5+
// RUN: %T/ListTests --verify %t_json > %t_verify
66
// RUN: %{xctest_checker} %t_verify verify_json.expected
77

88
#if os(Linux) || os(FreeBSD)

Tests/Functional/NegativeAccuracyTestCase/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/NegativeAccuracyTestCase
2-
// RUN: %{built_tests_dir}/NegativeAccuracyTestCase > %t || true
1+
// RUN: %{swiftc} %s -o %T/NegativeAccuracyTestCase
2+
// RUN: %T/NegativeAccuracyTestCase > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Observation/All/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/All
2-
// RUN: %{built_tests_dir}/All > %t || true
1+
// RUN: %{swiftc} %s -o %T/All
2+
// RUN: %T/All > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Observation/Selected/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Selected
2-
// RUN: %{built_tests_dir}/Selected Selected.ExecutedTestCase/test_executed > %t || true
1+
// RUN: %{swiftc} %s -o %T/Selected
2+
// RUN: %T/Selected Selected.ExecutedTestCase/test_executed > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Performance/Misuse/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/PerformanceMisuse
2-
// RUN: %{built_tests_dir}/PerformanceMisuse > %t || true
1+
// RUN: %{swiftc} %s -o %T/PerformanceMisuse
2+
// RUN: %T/PerformanceMisuse > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/Performance/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/Performance
2-
// RUN: %{built_tests_dir}/Performance > %t || true
1+
// RUN: %{swiftc} %s -o %T/Performance
2+
// RUN: %T/Performance > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/SelectedTest/main.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/SelectedTest
2-
// RUN: %{built_tests_dir}/SelectedTest SelectedTest.ExecutedTestCase/test_foo > %T/one_test_case || true
3-
// RUN: %{built_tests_dir}/SelectedTest SelectedTest.ExecutedTestCase > %T/one_test_case_class || true
4-
// RUN: %{built_tests_dir}/SelectedTest > %T/all || true
1+
// RUN: %{swiftc} %s -o %T/SelectedTest
2+
// RUN: %T/SelectedTest SelectedTest.ExecutedTestCase/test_foo > %T/one_test_case || true
3+
// RUN: %T/SelectedTest SelectedTest.ExecutedTestCase > %T/one_test_case_class || true
4+
// RUN: %T/SelectedTest > %T/all || true
55
// RUN: %{xctest_checker} -p "// CHECK-METHOD:" %T/one_test_case %s
66
// RUN: %{xctest_checker} -p "// CHECK-CLASS:" %T/one_test_case_class %s
77
// RUN: %{xctest_checker} -p "// CHECK-ALL:" %T/all %s

Tests/Functional/SingleFailingTestCase/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/SingleFailingTestCase
2-
// RUN: %{built_tests_dir}/SingleFailingTestCase > %t || true
1+
// RUN: %{swiftc} %s -o %T/SingleFailingTestCase
2+
// RUN: %T/SingleFailingTestCase > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/TestCaseLifecycle/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %{swiftc} %s -o %{built_tests_dir}/TestCaseLifecycle
2-
// RUN: %{built_tests_dir}/TestCaseLifecycle > %t || true
1+
// RUN: %{swiftc} %s -o %T/TestCaseLifecycle
2+
// RUN: %T/TestCaseLifecycle > %t || true
33
// RUN: %{xctest_checker} %t %s
44

55
#if os(Linux) || os(FreeBSD)

Tests/Functional/lit.cfg

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ else:
8181
# Having prepared the swiftc command, we set the substitution.
8282
config.substitutions.append(('%{swiftc}', ' '.join(swift_exec)))
8383

84-
# Add the %built_tests_dir substitution, which is a temporary
85-
# directory used to store built files.
86-
built_tests_dir = tempfile.mkdtemp()
87-
config.substitutions.append(('%{built_tests_dir}', built_tests_dir))
88-
8984
# Add the %xctest_checker substitution, which is a Python script
9085
# can be used to compare the actual XCTest output to the expected
9186
# output.

0 commit comments

Comments
 (0)