Translate user-facing runtime output to English, machine prefixes preserved, + CLI output test (#67, #85)
* feat: standardize runtime output in English * test: cover English CLI output
This commit is contained in:
@@ -5,7 +5,7 @@ from tools.benchmark_cuda_fixture import parse_output
|
||||
|
||||
SAMPLE = """
|
||||
REPLAY decode: 4 tokens | 12.34 tok/s
|
||||
PROFILO: expert-disk 1.25s | expert-matmul 2.50s | attention 0.75s | lm_head 0.10s | altro -0.05s
|
||||
PROFILE: expert-disk 1.25s | expert-matmul 2.50s | attention 0.75s | lm_head 0.10s | other -0.05s
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
HERE = Path(__file__).resolve().parent.parent
|
||||
CLI = HERE / "coli"
|
||||
|
||||
|
||||
class CliOutputLanguageTest(unittest.TestCase):
|
||||
def run_cli(self, *args):
|
||||
return subprocess.run(
|
||||
[sys.executable, str(CLI), *args],
|
||||
cwd=HERE,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
def test_help_is_english(self):
|
||||
result = self.run_cli("--help")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn("run GLM-5.2 locally", result.stdout)
|
||||
self.assertIn("automatically apply the RAM/VRAM plan", result.stdout)
|
||||
self.assertNotIn("modello", result.stdout.lower())
|
||||
self.assertNotIn("motore", result.stdout.lower())
|
||||
|
||||
def test_info_status_is_english(self):
|
||||
with tempfile.TemporaryDirectory() as model:
|
||||
result = self.run_cli("info", "--model", model)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn("config.json is missing", result.stdout)
|
||||
self.assertIn("disk", result.stdout)
|
||||
self.assertIn("engine", result.stdout)
|
||||
|
||||
def test_missing_model_error_is_english(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
missing_model = str(Path(directory) / "missing-model")
|
||||
result = self.run_cli("run", "--model", missing_model, "hello")
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn("model not found", result.stderr)
|
||||
self.assertIn("set COLI_MODEL or use --model", result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+2
-2
@@ -5,10 +5,10 @@
|
||||
#include "../tok.h"
|
||||
|
||||
int main(int argc, char **argv){
|
||||
if(argc<2){ fprintf(stderr,"uso: %s tokenizer.json < casi\n",argv[0]); return 1; }
|
||||
if(argc<2){ fprintf(stderr,"usage: %s tokenizer.json < cases\n",argv[0]); return 1; }
|
||||
Tok T;
|
||||
tok_load(&T, argv[1]);
|
||||
fprintf(stderr,"caricato: vocab_ids=%d specials=%d\n", T.n_ids, T.nsp);
|
||||
fprintf(stderr,"loaded: vocab_ids=%d specials=%d\n", T.n_ids, T.nsp);
|
||||
char *line=NULL; size_t cap=0; ssize_t nr;
|
||||
int pass=0, tot=0, dpass=0;
|
||||
while((nr=getline(&line,&cap,stdin))>=0){
|
||||
|
||||
Reference in New Issue
Block a user