Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion host-setup/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function Invoke-Upgrade {
# Installs only what is named, since the agent tools are never installed as a set nobody chose.
function Invoke-AgentsInstall {
if ($script:AGENT_NAMES.Count -eq 0) { die "-Agents takes the tools to install, separated by commas, or 'all'" }
if ($script:AGENT_NAMES -contains 'all') {
if ($script:AGENT_NAMES -ccontains 'all') {
if ($script:AGENT_NAMES.Count -gt 1) { die "-Agents takes 'all' alone, or a list of tool names" }
Invoke-Tool -Tool 'install-agents.ps1' -Arguments '-Install', '-All'
return
Expand Down
6 changes: 3 additions & 3 deletions host-setup/windows/install-agents.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ $TOOLS = @(

function Get-Tool {
param([string]$ToolName)
return ($script:TOOLS | Where-Object { $_.Name -eq $ToolName } | Select-Object -First 1)
return ($script:TOOLS | Where-Object { $_.Name -ceq $ToolName } | Select-Object -First 1)
}

# --- Report ---
Expand Down Expand Up @@ -564,7 +564,7 @@ function Show-List {
function Resolve-Selection {
$names = @($script:TOOLS | ForEach-Object { $_.Name })
foreach ($candidate in $script:WANT_TOOLS) {
if ($names -notcontains $candidate) { die "Unknown tool `"$candidate`", -List names the managed tools" }
if ($names -cnotcontains $candidate) { die "Unknown tool `"$candidate`", -List names the managed tools" }
}
if ($script:WANT_TOOLS.Count -eq 0) {
if ($script:MODE -eq 'install' -and -not $script:INSTALL_ALL) {
Expand All @@ -573,7 +573,7 @@ function Resolve-Selection {
return , $names
}
# Sorted into registry order rather than the order they were typed, so a run reads the same however it was asked for.
return , @($names | Where-Object { $script:WANT_TOOLS -contains $_ })
return , @($names | Where-Object { $script:WANT_TOOLS -ccontains $_ })
}

# The order the actions were given is not a contract, so more than one is a refusal rather than the last one winning.
Expand Down
18 changes: 18 additions & 0 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,15 @@ def test_agents_a_name_holding_a_space_and_all_is_not_all(self) -> None:
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn(f"install-agents.sh --install <{given}>", self.agents_steps())

def test_agents_all_in_another_case_is_a_tool_name_not_the_keyword(self) -> None:
expected: list[str] = []
for given in ("ALL", "All"):
with self.subTest(given=given):
result = self.run_main(action="--agents", args=(given,))
self.assertEqual(result.returncode, 0, result.stderr)
expected.append(f"install-agents.sh --install {given}")
self.assertEqual(self.agents_steps(), expected)

def test_agents_drops_empty_names_from_the_list(self) -> None:
result = self.run_main(action="--agents", args=("herdr,,cswap,",))
self.assertEqual(result.returncode, 0, result.stderr)
Expand Down Expand Up @@ -1879,6 +1888,15 @@ def test_all_alone_hands_off_as_an_install_of_all(self) -> None:
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(self.steps(), ["install-agents.ps1 -Install -All"], result.stdout)

def test_all_in_another_case_is_a_tool_name_not_the_keyword(self) -> None:
expected: list[str] = []
for given in ("ALL", "All"):
with self.subTest(given=given):
result = self.run_agents([given])
self.assertEqual(result.returncode, 0, result.stderr)
expected.append(f"install-agents.ps1 -Install {given}")
self.assertEqual(self.steps(), expected, result.stdout)

def test_all_beside_other_names_is_refused(self) -> None:
result = self.run_agents(["all,herdr"])
self.assertNotEqual(result.returncode, 0)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_install_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def test_refusals(self) -> None:
(("--upgrade", "--json"), "applies only to --report"),
(("--upgrade", "--all"), "--all names every tool for --install"),
(("--report", "nosuch"), 'Unknown tool "nosuch"'),
(("--report", "Herdr"), 'Unknown tool "Herdr"'),
(("--report", "--upgrade"), "More than one action"),
]:
with self.subTest(arguments=arguments):
Expand Down Expand Up @@ -367,6 +368,7 @@ def test_refusals(self) -> None:
(("-Upgrade", "-All"), "-All names every tool for -Install"),
(("-Install", "-All", "herdr"), "-All and a tool name were both given"),
(("-Report", "nosuch"), 'Unknown tool "nosuch"'),
(("-Report", "Herdr"), 'Unknown tool "Herdr"'),
]:
with self.subTest(arguments=arguments):
result = self.run_script(*arguments)
Expand Down
Loading