Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b6c92bf0a |
No files matched your search
@@ -66,6 +66,7 @@ jobs:
|
||||
python3 tests/test_discover_enrollment.py
|
||||
python3 tests/test_finish_enrollment.py
|
||||
python3 tests/test_run_enrollment.py
|
||||
python3 tests/test_install_reconcile_gh.py
|
||||
python3 tests/test_circle_project_settings.py
|
||||
python3 tests/test_static_analysis_exit.py
|
||||
python3 tests/test_validate_standard.py
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Capability probes must drain help output while still rejecting missing options."""
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
|
||||
class InstallerTests(unittest.TestCase):
|
||||
def probe(self, flags):
|
||||
installer = Path(__file__).resolve().parents[1] / 'tools/install_reconcile_gh.sh'
|
||||
checks = '\n'.join(line for line in installer.read_text().splitlines()
|
||||
if line.startswith(('gh api --help', 'gh pr merge --help')))
|
||||
self.assertEqual(2, len(checks.splitlines()))
|
||||
producer = ("import signal,sys; signal.signal(signal.SIGPIPE,signal.SIG_DFL); "
|
||||
f"print({flags!r},flush=True); sys.stdout.write('x'*1048576)")
|
||||
script = 'set -euo pipefail\ngh() { python3 -c ' + shlex.quote(producer) + '; }\n' + checks
|
||||
return subprocess.run(['bash', '-c', script], capture_output=True, timeout=10).returncode
|
||||
|
||||
def test_large_help_output_does_not_kill_producer(self):
|
||||
self.assertEqual(0, self.probe('--slurp --match-head-commit'))
|
||||
|
||||
def test_missing_required_option_fails(self):
|
||||
self.assertNotEqual(0, self.probe('--slurp'))
|
||||
self.assertNotEqual(0, self.probe('--match-head-commit'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -14,5 +14,6 @@ printf '%s %s\n' "$checksum" "$archive" | sha256sum --check --status
|
||||
tar -xOzf "$archive" "gh_${version}_linux_amd64/bin/gh" > "$binary"
|
||||
sudo install -m 0755 "$binary" /usr/local/bin/gh
|
||||
gh --version
|
||||
gh api --help | grep -q -- --slurp
|
||||
gh pr merge --help | grep -q -- --match-head-commit
|
||||
# Drain help output: grep -q can SIGPIPE gh under pipefail.
|
||||
gh api --help | grep -- --slurp >/dev/null
|
||||
gh pr merge --help | grep -- --match-head-commit >/dev/null
|
||||
Reference in new issue
Block a user