Skip to content

Commit

Permalink
Fix commands test generator for Xcode 12.5+
Browse files Browse the repository at this point in the history
Resolves: #87

- As of Xcode 12.5 using `swift run xcdiff` along with the `-v` (verbose) option produces additional unwanted output
- This is caused by `-v` now also being an option the `swift` command respect to produce verbose output
- To mitigate this, we no longer invoke `xcdiff` via `swift run xcdiff`, but instead we invoke the binary directly via `$(swift build --show-bin-path)/xcdiff` after it has been built

Test Plan:

- Run `make regenerate_command_snapshots`
- Verify it works when using Xcode12.5+

Signed-off-by: Kassem Wridan <kwridan@bloomberg.net>
  • Loading branch information
kwridan committed Aug 6, 2021
1 parent fbaf3dd commit fdc0e6f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Scripts/generate_tests_commands_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def is_not_blank(string):
def build_project():
subprocess.check_call(["swift", "build"])

def xcdiff_binary_path():
bin_path = subprocess.check_output(["swift", "build", "--show-bin-path"]).strip().decode()
return os.path.join(bin_path, "xcdiff")

def run_command(arguments):
arguments = [substitute_project_paths(element) for element in arguments]
print(arguments)
Expand All @@ -90,7 +94,7 @@ def generate_command_tests_files():
dirname = os.path.dirname(sys.argv[0])
command_tests_path = os.path.join(dirname, "../CommandTests/Generated")
commands = generate_commands() + COMMANDS
command_run = ["swift", "run", "xcdiff"]
command_run = [xcdiff_binary_path()]
remove_all_command_tests_files(command_tests_path)

for command in commands:
Expand Down

0 comments on commit fdc0e6f

Please sign in to comment.