# # # add_dir "tests/invoke_toplevel_group" # # add_file "tests/invoke_toplevel_group/__driver__.lua" # content [659b589cfaba2f10b2256937403524a911270d43] # # patch "tests/command_completion/__driver__.lua" # from [ee0178f91217398eb542779dc337333fbab2e86d] # to [99783bc246436c70cd35e25536511b2233c97c6c] # # patch "tests/test_the_help_command/__driver__.lua" # from [3696e97ef0a6066f245210bb27f24c5f27dc7e1d] # to [7d3281bae273ad0b83f68f083ae503f97148ea28] # ============================================================ --- tests/invoke_toplevel_group/__driver__.lua 659b589cfaba2f10b2256937403524a911270d43 +++ tests/invoke_toplevel_group/__driver__.lua 659b589cfaba2f10b2256937403524a911270d43 @@ -0,0 +1,12 @@ + +mtn_setup() + +-- Invoking a group fails with an appropriate error message. +check(mtn("review"), 1, "", true) +output = readfile("stderr") +check(string.find(output, "is invalid; it is a group") ~= nil) + +-- Command completion does not work on groups. +check(mtn("revie"), 1, "", true) +output = readfile("stderr") +check(string.find(output, "unknown command") ~= nil) ============================================================ --- tests/command_completion/__driver__.lua ee0178f91217398eb542779dc337333fbab2e86d +++ tests/command_completion/__driver__.lua 99783bc246436c70cd35e25536511b2233c97c6c @@ -1,10 +1,29 @@ mtn_setup() mtn_setup() +-- Completion of a command. check(mtn("status"), 0, false, false) check(mtn("st"), 0, false, false) check(mtn("s"), 1, false, false) +-- Completion of a command. check(mtn("diff"), 0, false, false) check(mtn("dif"), 0, false, false) check(mtn("di"), 1, false, false) + +-- Completion of a subcommand at the second level. +check(mtn("list", "key"), 0, false, false) +check(mtn("list", "ke"), 0, false, false) +check(mtn("list", "k"), 1, false, false) + +-- Completion of a subcommand at the first level. +check(mtn("list", "keys"), 0, false, false) +check(mtn("lis", "keys"), 0, false, false) +check(mtn("li", "keys"), 0, false, false) +check(mtn("l", "keys"), 0, false, false) + +-- Completion of a subcommand at the two levels. +check(mtn("list", "keys"), 0, false, false) +check(mtn("lis", "key"), 0, false, false) +check(mtn("li", "ke"), 0, false, false) +check(mtn("l", "k"), 1, false, false) ============================================================ --- tests/test_the_help_command/__driver__.lua 3696e97ef0a6066f245210bb27f24c5f27dc7e1d +++ tests/test_the_help_command/__driver__.lua 7d3281bae273ad0b83f68f083ae503f97148ea28 @@ -1,7 +1,51 @@ mtn_setup() mtn_setup() +-- The 'help' command behaves exactly as the '--help' option. check(mtn("help", "mv"), 0, true, 0) rename("stdout", "out") check(mtn("--help", "mv"), 0, true, 0) check(samefile("stdout", "out")) + +-- Help on a top-level group. +check(mtn("help", "review"), 0, true, "") +output = readfile("stdout") +check(string.find(output, "Commands in group 'review'") ~= nil) + +-- Help on a top-level group; completion not supported. +check(mtn("help", "revie"), 1, "", true) +output = readfile("stderr") +check(string.find(output, "unknown command") ~= nil) + +-- Help on a command group. +check(mtn("help", "list"), 0, true, "") +output = readfile("stdout") +check(string.find(output, "Subcommands of 'mtn list'") ~= nil) +check(string.find(output, "Description for 'mtn list'") ~= nil) +check(string.find(output, "Aliases: ls.") ~= nil) + +-- Help on a command group using one of its aliases. +check(mtn("help", "ls"), 0, true, "") +output = readfile("stdout") +check(string.find(output, "Subcommands of 'mtn ls'") ~= nil) +check(string.find(output, "Description for 'mtn ls'") ~= nil) +check(string.find(output, "Aliases: list.") ~= nil) + +-- Help on a command with additional options. +check(mtn("help", "checkout"), 0, true, "") +output = readfile("stdout") +check(string.find(output, "Options specific to 'mtn checkout'") ~= nil) +check(string.find(output, "Description for 'mtn checkout'") ~= nil) +check(string.find(output, "--branch") ~= nil) + +-- Help on a subcommand. +check(mtn("help", "list", "keys"), 0, true, "") +output = readfile("stdout") +check(string.find(output, "Syntax specific to 'mtn list keys'") ~= nil) +check(string.find(output, "Description for 'mtn list keys'") ~= nil) + +-- Help on a subcommand using an alias for the intermediate name. +check(mtn("help", "ls", "keys"), 0, true, "") +output = readfile("stdout") +check(string.find(output, "Syntax specific to 'mtn ls keys'") ~= nil) +check(string.find(output, "Description for 'mtn ls keys'") ~= nil)