Skip to content

Commit e6d7a7c

Browse files
committed
Fix path resoltion in lit testing
1 parent 7970039 commit e6d7a7c

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

build-script.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -523,22 +523,33 @@ def check_incr_transfer_roundtrip_exec() -> None:
523523
)
524524

525525

526-
def find_lit_test_helper_exec(
527-
toolchain: str, build_dir: Optional[str], release: bool
526+
def find_swiftpm_bin_path(
527+
package_dir: str, toolchain: str, build_dir: Optional[str], release: bool
528528
) -> str:
529529
swiftpm_call = get_swiftpm_invocation(
530530
toolchain=toolchain,
531531
action="build",
532-
package_dir=PACKAGE_DIR,
532+
package_dir=package_dir,
533533
build_dir=build_dir,
534534
multiroot_data_file=None,
535535
release=release,
536536
)
537-
swiftpm_call.extend(["--product", "lit-test-helper"])
538537
swiftpm_call.extend(["--show-bin-path"])
539538

540539
bin_dir = subprocess.check_output(swiftpm_call)
541-
return os.path.join(bin_dir.strip().decode('utf-8'), "lit-test-helper")
540+
return bin_dir.strip().decode('utf-8')
541+
542+
543+
def find_product_bin_path(
544+
toolchain: str, build_dir: Optional[str], release: bool
545+
) -> str:
546+
return find_swiftpm_bin_path(PACKAGE_DIR, toolchain, build_dir, release)
547+
548+
549+
def find_examples_bin_path(
550+
toolchain: str, build_dir: Optional[str], release: bool
551+
) -> str:
552+
return find_swiftpm_bin_path(EXAMPLES_DIR, toolchain, build_dir, release)
542553

543554

544555
def run_lit_tests(toolchain: str, build_dir: Optional[str], release: bool,
@@ -548,9 +559,12 @@ def run_lit_tests(toolchain: str, build_dir: Optional[str], release: bool,
548559
check_lit_exec()
549560
check_incr_transfer_roundtrip_exec()
550561

551-
lit_test_helper_exec = find_lit_test_helper_exec(
552-
toolchain=toolchain, build_dir=build_dir, release=release
553-
)
562+
product_bin_path = find_product_bin_path(
563+
toolchain=toolchain, build_dir=build_dir, release=release)
564+
examples_bin_path = find_examples_bin_path(
565+
toolchain=toolchain, build_dir=build_dir, release=release)
566+
567+
lit_test_helper_exec = os.path.join(product_bin_path, "lit-test-helper")
554568

555569
lit_call = ["python3", LIT_EXEC]
556570
lit_call.append(os.path.join(PACKAGE_DIR, "lit_tests"))
@@ -562,11 +576,7 @@ def run_lit_tests(toolchain: str, build_dir: Optional[str], release: bool,
562576
lit_call.extend(
563577
["--param", "INCR_TRANSFER_ROUND_TRIP.PY=" + INCR_TRANSFER_ROUNDTRIP_EXEC]
564578
)
565-
566-
build_subdir = 'release' if release else 'debug'
567-
package_build_dir = build_dir + '/' + build_subdir
568-
569-
lit_call.extend(["--param", "BUILD_DIR=" + package_build_dir])
579+
lit_call.extend(["--param", "EXAMPLES_BIN_PATH=" + examples_bin_path])
570580
lit_call.extend(["--param", "TOOLCHAIN=" + toolchain])
571581

572582
# Print all failures
@@ -662,7 +672,7 @@ def verify_source_code_command(args: argparse.Namespace) -> None:
662672
def build_command(args: argparse.Namespace) -> None:
663673
try:
664674
builder = Builder(
665-
toolchain=args.toolchain,
675+
toolchain=realpath(args.toolchain),
666676
build_dir=realpath(args.build_dir),
667677
multiroot_data_file=args.multiroot_data_file,
668678
release=args.release,
@@ -685,7 +695,7 @@ def build_command(args: argparse.Namespace) -> None:
685695
def test_command(args: argparse.Namespace) -> None:
686696
try:
687697
builder = Builder(
688-
toolchain=args.toolchain,
698+
toolchain=realpath(args.toolchain),
689699
build_dir=realpath(args.build_dir),
690700
multiroot_data_file=args.multiroot_data_file,
691701
release=args.release,
@@ -697,7 +707,7 @@ def test_command(args: argparse.Namespace) -> None:
697707
builder.buildExample("ExamplePlugin")
698708

699709
run_tests(
700-
toolchain=args.toolchain,
710+
toolchain=realpath(args.toolchain),
701711
build_dir=realpath(args.build_dir),
702712
multiroot_data_file=args.multiroot_data_file,
703713
release=args.release,

lit_tests/compiler_plugin_basic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: %swift-frontend -typecheck -swift-version 5 \
66
// RUN: -enable-experimental-feature Macros \
77
// RUN: -dump-macro-expansions \
8-
// RUN: -load-plugin-executable %build_dir/ExamplePlugin#ExamplePlugin \
8+
// RUN: -load-plugin-executable %examples_bin_path/ExamplePlugin#ExamplePlugin \
99
// RUN -module-name MyApp \
1010
// RUN: %s > %t/expansions-dump.txt 2>&1
1111
//

lit_tests/lit.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ config.suffixes = [".swift"]
5959
config.test_format = lit.formats.ShTest(execute_external=True)
6060
config.test_exec_root = tempfile.gettempdir()
6161

62-
config.build_dir = lit_config.params.get("BUILD_DIR")
62+
config.examples_bin_path = lit_config.params.get("EXAMPLES_BIN_PATH")
6363
config.filecheck = inferSwiftBinary("FileCheck")
6464
config.incr_transfer_round_trip = inferSwiftBinary("incr_transfer_round_trip.py")
6565
config.lit_test_helper = inferSwiftBinary("lit-test-helper")
@@ -71,9 +71,9 @@ config.swift_frontend = inferSwiftBinary("swift-frontend")
7171
# // REQUIRES: platform=<platform>
7272
# where <platform> is Linux or Darwin
7373
# Add a platform feature.
74-
config.available_features.add("platform="+platform.system())
74+
config.available_features.add("platform=" + platform.system())
7575

76-
config.substitutions.append(("%build_dir", config.build_dir))
76+
config.substitutions.append(("%examples_bin_path", config.examples_bin_path))
7777
config.substitutions.append(
7878
("%empty-directory\(([^)]+)\)", 'rm -rf "\\1" && mkdir -p "\\1"')
7979
)

0 commit comments

Comments
 (0)