merging
This commit is contained in:
+60
-2
@@ -13,6 +13,7 @@
|
||||
% gso_tokens/1
|
||||
%]).
|
||||
-export([start/1]).
|
||||
-export([do_help/0]).
|
||||
|
||||
-include("$gsc_include/gsc.hrl").
|
||||
-include("ansi.hrl").
|
||||
@@ -21,7 +22,64 @@ do_help() ->
|
||||
io:format("~ts", [help_screen()]).
|
||||
|
||||
help_screen() ->
|
||||
["you can't help people who refuse to help themsleves\n"].
|
||||
["Usage: gsc <command> [args]\n"
|
||||
"\n"
|
||||
"COMMANDS\n"
|
||||
"\n"
|
||||
" (no args)\n"
|
||||
" shell\n"
|
||||
" eshell\n"
|
||||
" Start an Erlang shell with GSC loaded.\n"
|
||||
"\n"
|
||||
" tokens <file>\n"
|
||||
" Print GSC tokens from <file>, one per line.\n"
|
||||
"\n"
|
||||
" tokens -c <file>\n"
|
||||
" tokens --color <file>\n"
|
||||
" tcat <file>\n"
|
||||
" ctokens <file>\n"
|
||||
" color_tokens <file>\n"
|
||||
" Print <file> to stdout with each token highlighted in a\n"
|
||||
" different color so token boundaries are visible.\n"
|
||||
"\n"
|
||||
" gso tokens <file>\n"
|
||||
" gso_tokens <file>\n"
|
||||
" Print sophia-compatible (so_scan) tokens from <file>,\n"
|
||||
" one per line.\n"
|
||||
"\n"
|
||||
" rmm <file>\n"
|
||||
" Compile <file> and call its main/0 with GSC context loaded.\n"
|
||||
" Useful for running scratch scripts.\n"
|
||||
"\n"
|
||||
"TEST HARNESS (gsc test ...)\n"
|
||||
"\n"
|
||||
" gsc test -l\n"
|
||||
" gsc test --list\n"
|
||||
" List available named tests.\n"
|
||||
"\n"
|
||||
" gsc test -a\n"
|
||||
" gsc test --all\n"
|
||||
" Run all named tests.\n"
|
||||
"\n"
|
||||
" gsc test so tokens <file>\n"
|
||||
" gsc test so_tokens <file>\n"
|
||||
" Print sophia-original (so_scan) tokens from <file>,\n"
|
||||
" one per line.\n"
|
||||
"\n"
|
||||
" gsc test tokenizers_agree <file>\n"
|
||||
" Check whether gsc and so_scan produce identical tokens\n"
|
||||
" for <file>. Prints 'true' or 'false'.\n"
|
||||
" <file> is resolved relative to cwd.\n"
|
||||
" Example:\n"
|
||||
" gsc test tokenizers_agree foo.aes\n"
|
||||
"\n"
|
||||
" gsc test <name>\n"
|
||||
" Run a named test module. 'gsc test foo' and\n"
|
||||
" 'gsc test gsc_test_foo' are equivalent.\n"
|
||||
" Use 'gsc test --list' to see available names.\n"
|
||||
"\n"
|
||||
].
|
||||
|
||||
|
||||
-spec start(ArgV) -> ok
|
||||
when ArgV :: [string()].
|
||||
@@ -42,7 +100,7 @@ start(ArgV) ->
|
||||
do(["test" | Tests]) ->
|
||||
do_test(Tests);
|
||||
% slowly phasing out shitty names like lctokens
|
||||
% tokens = native sfc token representation
|
||||
% tokens = native gsc token representation
|
||||
do(["tokens", Foo]) -> do_tokens(Foo);
|
||||
% print source file to screen with token boundaries
|
||||
% highlighted
|
||||
|
||||
@@ -121,8 +121,8 @@ concat_property(FileName, FilePath) ->
|
||||
{FileName ++ ": file = sum(tokens)",
|
||||
fun() ->
|
||||
case gsc:tokens_from_file(FileChars) of
|
||||
{ok, SfcTokens} ->
|
||||
ConcatStr = concat_token_strs(SfcTokens, []),
|
||||
{ok, GscTokens} ->
|
||||
ConcatStr = concat_token_strs(GscTokens, []),
|
||||
?assertEqual(FileChars, ConcatStr);
|
||||
_Error ->
|
||||
ok
|
||||
|
||||
+9
-6
@@ -24,8 +24,8 @@ cli_args(TestNames) ->
|
||||
ts_utils:tidily(fun() -> do_gsc_test(TestNames) end).
|
||||
|
||||
|
||||
do_gsc_test(["-h" | _]) -> do_help();
|
||||
do_gsc_test(["--help" | _]) -> do_help();
|
||||
%do_gsc_test(["-h" | _]) -> do_help();
|
||||
%do_gsc_test(["--help" | _]) -> do_help();
|
||||
do_gsc_test(["-l" | _]) -> do_list();
|
||||
do_gsc_test(["--list" | _]) -> do_list();
|
||||
do_gsc_test(["-a" | _]) -> do_all();
|
||||
@@ -35,14 +35,17 @@ do_gsc_test(["so", "tokens", X]) -> do_so_tokens(X);
|
||||
do_gsc_test(["tokenizers_agree", X]) ->
|
||||
do_tokenizers_agree(X);
|
||||
do_gsc_test([TestName]) ->
|
||||
ts_utils:run_test_by_name(TestName);
|
||||
case ts_utils:test_exists_by_name(TestName) of
|
||||
true -> ts_utils:run_test_by_name(TestName);
|
||||
false -> gsc_cli:do_help()
|
||||
end;
|
||||
do_gsc_test(_) ->
|
||||
do_help().
|
||||
gsc_cli:do_help().
|
||||
|
||||
|
||||
|
||||
do_help() ->
|
||||
io:format("go help yourself~n").
|
||||
%do_help() ->
|
||||
% io:format("go help yourself~n").
|
||||
|
||||
do_list() ->
|
||||
Names = ts_utils:runnable_test_names(),
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
load_dep/1,
|
||||
clean_after/1, tidily/1,
|
||||
delete_beams/0, tidy/0,
|
||||
test_exists_by_name/1,
|
||||
run_test_by_name/1,
|
||||
rmm/1, run_mod_main/1,
|
||||
runnable_test_names/0,
|
||||
@@ -110,6 +111,13 @@ tidy() ->
|
||||
delete_beams().
|
||||
|
||||
|
||||
test_exists_by_name(Name) when is_list(Name) ->
|
||||
case find_test_by_name(Name) of
|
||||
{good, _} -> true;
|
||||
{bad, _} -> true;
|
||||
not_found -> false
|
||||
end.
|
||||
|
||||
-spec run_test_by_name(Name) -> Result when
|
||||
Name :: string(),
|
||||
Result :: ok.
|
||||
|
||||
Reference in New Issue
Block a user