File tree Expand file tree Collapse file tree 3 files changed +83
-0
lines changed
test/internal/custom_toolchain Expand file tree Collapse file tree 3 files changed +83
-0
lines changed Original file line number Diff line number Diff line change
1
+ load ("//xcodeproj/internal:custom_toolchain.bzl" , "custom_toolchain" )
2
+
3
+ # Example swiftc override for testing
4
+ filegroup (
5
+ name = "test_swiftc" ,
6
+ srcs = ["test_swiftc.sh" ],
7
+ visibility = ["//visibility:public" ],
8
+ )
9
+
10
+ # Test target for custom_toolchain
11
+ custom_toolchain (
12
+ name = "test_toolchain" ,
13
+ toolchain_name = "TestCustomToolchain" ,
14
+ overrides = {
15
+ # Key is a label target, value is the tool name
16
+ ":test_swiftc" : "swiftc" ,
17
+ },
18
+ )
19
+
20
+ # Add a simple test rule that depends on the toolchain
21
+ sh_test (
22
+ name = "custom_toolchain_test" ,
23
+ srcs = ["custom_toolchain_test.sh" ],
24
+ data = [":test_toolchain" ],
25
+ args = ["$(location :test_toolchain)" ],
26
+ )
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ # The first argument should be the path to the toolchain directory
6
+ TOOLCHAIN_DIR=" $1 "
7
+
8
+ echo " Verifying toolchain at: $TOOLCHAIN_DIR "
9
+
10
+ # Check that the toolchain directory exists
11
+ if [[ ! -d " $TOOLCHAIN_DIR " ]]; then
12
+ echo " ERROR: Toolchain directory does not exist: $TOOLCHAIN_DIR "
13
+ exit 1
14
+ fi
15
+
16
+ # Check that ToolchainInfo.plist exists
17
+ if [[ ! -f " $TOOLCHAIN_DIR /ToolchainInfo.plist" ]]; then
18
+ echo " ERROR: ToolchainInfo.plist not found in toolchain"
19
+ exit 1
20
+ fi
21
+
22
+ # Check for correct identifiers in the plist
23
+ if ! grep -q " BazelRulesXcodeProj" " $TOOLCHAIN_DIR /ToolchainInfo.plist" ; then
24
+ echo " ERROR: ToolchainInfo.plist doesn't contain BazelRulesXcodeProj"
25
+ exit 1
26
+ fi
27
+
28
+ # Check that our custom swiftc is properly linked/copied
29
+ if [[ ! -f " $TOOLCHAIN_DIR /usr/bin/swiftc" ]]; then
30
+ echo " ERROR: swiftc not found in toolchain"
31
+ exit 1
32
+ fi
33
+
34
+ # Ensure swiftc is executable
35
+ if [[ ! -x " $TOOLCHAIN_DIR /usr/bin/swiftc" ]]; then
36
+ echo " ERROR: swiftc is not executable"
37
+ exit 1
38
+ fi
39
+
40
+ # Test if the swiftc actually runs
41
+ if ! " $TOOLCHAIN_DIR /usr/bin/swiftc" --version > /dev/null 2>&1 ; then
42
+ echo " WARN: swiftc doesn't run correctly, but this is expected in tests"
43
+ fi
44
+
45
+ echo " Custom toolchain validation successful!"
46
+ exit 0
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # This is a test script that simulates a custom Swift compiler
4
+ # It will be used as an override in the custom toolchain
5
+
6
+ # Print inputs for debugging
7
+ echo " Custom swiftc called with args: $@ " >&2
8
+
9
+ # In a real override, you would do something meaningful with the args
10
+ # For testing, just exit successfully
11
+ exit 0
You can’t perform that action at this time.
0 commit comments