Skip to content

Commit

Permalink
Fix test_completion by setting WHATEVER
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Jan 18, 2025
1 parent 594f2b3 commit 41156ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,9 @@ def print_completion(*args):
b"/opt/local/share/bash-completion/bash_completion",
# Homebrew (before bash-completion2)
b"/usr/local/etc/bash_completion",
b"/opt/homebrew/etc/profile.d/",
b"/opt/homebrew/etc/profile.d/bash_completion",
b"/opt/homebrew/etc/profile.d/bash_completion.sh",
]


Expand All @@ -2443,6 +2446,7 @@ def completion_script(commands):
completion data for.
"""
base_script = os.path.join(os.path.dirname(__file__), "completion_base.sh")
print(base_script)
with open(base_script) as base_script:
yield base_script.read()

Expand Down
1 change: 1 addition & 0 deletions beets/ui/completion_base.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# This file is part of beets.
# Copyright (c) 2014, Thomas Scholtes.
#
Expand Down
8 changes: 7 additions & 1 deletion test/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,6 @@ def test_completion(self):
tester = subprocess.Popen(
cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env
)

# Load bash_completion library.
for path in commands.BASH_COMPLETION_PATHS:
if os.path.exists(syspath(path)):
Expand All @@ -1426,18 +1425,25 @@ def test_completion(self):
except OSError:
self.skipTest("could not read bash-completion script")

print("right before Load completion script")
# Load completion script.
self.io.install()
print("right after io.install command")
self.run_command("completion", lib=None)
print("right after run_command")
completion_script = self.io.getoutput().encode("utf-8")
self.io.restore()
tester.stdin.writelines(completion_script.splitlines(True))
print("right after Load completion script block")

# Load test suite.
test_script_name = os.path.join(_common.RSRC, b"test_completion.sh")
with open(test_script_name, "rb") as test_script_file:
tester.stdin.writelines(test_script_file)
out, err = tester.communicate()
print("err from tester")
print(err)
print()
assert tester.returncode == 0
assert out == b"completion tests passed\n", (
"test/test_completion.sh did not execute properly. "
Expand Down

0 comments on commit 41156ef

Please sign in to comment.