package cli import ( "testing" ) func TestAFlagIsNotSatisfiedByALongerOne(t *testing.T) { // The failure this guards against is silent: --port would be reported as // present because --port-range is documented, and a renamed flag would sail // through the check that exists to catch renamed flags. help := " --port-range N a range\n --model-name S a name\n" if mentions(help, "--port") { t.Error("--port was satisfied by --port-range") } if mentions(help, "--model") { t.Error("--model was satisfied by --model-name") } if !mentions(help, "--port-range") { t.Error("--port-range was not found") } } func TestFlagsAreFoundInTheShapesHelpTextUses(t *testing.T) { help := ` -m, --model FNAME model path --host HOST ip address --parallel, -np N slots --metrics enable prometheus --alias=NAME served name ` for _, flag := range []string{"--model", "--host", "--parallel", "--metrics", "--alias"} { if !mentions(help, flag) { t.Errorf("%s was not found in a help text that documents it", flag) } } for _, flag := range []string{"--nonsense", "--mode", "--para"} { if mentions(help, flag) { t.Errorf("%s was found in a help text that does not document it", flag) } } } func TestTheRepresentativeShardIsTheWidestOne(t *testing.T) { // A flag that only appears in the multi-node case is exactly the one nobody // notices has been renamed, so the command built for checking has to be the // widest llmgw would ever produce. spec := representativeShard("vllm", 2, 8, 4) if spec.NNodes != 2 || spec.Profile.Nodes != 2 { t.Errorf("not a multi-node shard: %+v", spec) } if len(spec.GPUIndices) != 4 { t.Errorf("%d GPUs, want 4", len(spec.GPUIndices)) } if spec.LeaderAddr == "" || spec.LeaderPort == 0 { t.Error("no rendezvous point, so the flags that carry it will not appear") } } func TestATruncatedHelpIsSuspected(t *testing.T) { // Found by truncating llama.cpp's 725-line help to 400 lines and being told, // confidently, that five flags the running cluster uses do not exist. full := " --help show this\n --model F path\n" if !mentions(full, "--help") { t.Fatal("the guard's own signal is missing from a complete help") } truncated := " --model F path\n" if mentions(truncated, "--help") { t.Error("a truncated help was taken for a complete one") } }