diff options
Diffstat (limited to 'lib/parsetools/test/leex_SUITE.erl')
| -rw-r--r-- | lib/parsetools/test/leex_SUITE.erl | 89 | 
1 files changed, 84 insertions, 5 deletions
diff --git a/lib/parsetools/test/leex_SUITE.erl b/lib/parsetools/test/leex_SUITE.erl index afedd79a4e..eb15bebf63 100644 --- a/lib/parsetools/test/leex_SUITE.erl +++ b/lib/parsetools/test/leex_SUITE.erl @@ -1,4 +1,3 @@ -%% -*- coding: utf-8 -*-  %%  %% %CopyrightBegin%  %%  @@ -45,7 +44,7 @@  	 pt/1, man/1, ex/1, ex2/1, not_yet/1, -         otp_10302/1]). +         otp_10302/1, otp_11286/1, unicode/1]).  % Default timetrap timeout (set in init_per_testcase).  -define(default_timeout, ?t:minutes(1)). @@ -66,8 +65,8 @@ all() ->  groups() ->       [{checks, [], [file, compile, syntax]}, -     {examples, [], [pt, man, ex, ex2, not_yet]}, -     {tickets, [], [otp_10302]}]. +     {examples, [], [pt, man, ex, ex2, not_yet, unicode]}, +     {tickets, [], [otp_10302, otp_11286]}].  init_per_suite(Config) ->      Config. @@ -401,6 +400,24 @@ pt(Config) when is_list(Config) ->      ?line run(Config, Ts),      ok. +unicode(suite) -> +    []; +unicode(Config) when is_list(Config) -> +    Ts = [{unicode_1,  +	   <<"%% -*- coding: utf-8 -*-\n" +	     "Definitions.\n" +	     "RTLarrow    = (←)\n" +	     "Rules.\n" +	     "{RTLarrow}  : {token,{'<-',TokenLine}}.\n" +	     "Erlang code.\n" +	     "-export([t/0]).\n" +	     "t() -> {ok, [{'<-', 1}], 1} = string(\"←\"), ok.">>, +           default, +           ok}], + +    ?line run(Config, Ts), +    ok. +  man(doc) ->      "Examples from the manpage.";  man(suite) -> []; @@ -983,6 +1000,68 @@ otp_10302(Config) when is_list(Config) ->      ok. +otp_11286(doc) -> +    "OTP-11286. A Unicode filename bug; both Leex and Yecc."; +otp_11286(suite) -> []; +otp_11286(Config) when is_list(Config) -> +    Node = start_node(otp_11286, "+fnu"), +    Dir = ?privdir, +    UName = [1024] ++ "u", +    UDir = filename:join(Dir, UName), +    ok = rpc:call(Node, file, make_dir, [UDir]), + +    %% Note: Cannot use UName as filename since the filename is used +    %% as module name. To be fixed in R18. +    Filename = filename:join(UDir, 'OTP-11286.xrl'), +    Scannerfile = filename:join(UDir, 'OTP-11286.erl'), +    Options = [return, {scannerfile, Scannerfile}], + +    Mini1 = <<"%% coding: utf-8\n" +              "Definitions.\n" +              "D  = [0-9]\n" +              "Rules.\n" +              "{L}+  : {token,{word,TokenLine,TokenChars}}.\n" +              "Erlang code.\n">>, +    ok = rpc:call(Node, file, write_file, [Filename, Mini1]), +    {ok, _, []} = rpc:call(Node, leex, file, [Filename, Options]), +    {ok,_,_} = rpc:call(Node, compile, file, +                  [Scannerfile,[basic_validation,return]]), + +    Mini2 = <<"Definitions.\n" +              "D  = [0-9]\n" +              "Rules.\n" +              "{L}+  : {token,{word,TokenLine,TokenChars}}.\n" +              "Erlang code.\n">>, +    ok = rpc:call(Node, file, write_file, [Filename, Mini2]), +    {ok, _, []} = rpc:call(Node, leex, file, [Filename, Options]), +    {ok,_,_} = rpc:call(Node, compile, file, +                  [Scannerfile,[basic_validation,return]]), + +    Mini3 = <<"%% coding: latin-1\n" +              "Definitions.\n" +              "D  = [0-9]\n" +              "Rules.\n" +              "{L}+  : {token,{word,TokenLine,TokenChars}}.\n" +              "Erlang code.\n">>, +    ok = rpc:call(Node, file, write_file, [Filename, Mini3]), +    {ok, _, []} = rpc:call(Node, leex, file, [Filename, Options]), +    {ok,_,_} = rpc:call(Node, compile, file, +                  [Scannerfile,[basic_validation,return]]), + +    true = test_server:stop_node(Node), +    ok. + +start_node(Name, Args) -> +    [_,Host] = string:tokens(atom_to_list(node()), "@"), +    ct:log("Trying to start ~w@~s~n", [Name,Host]), +    case test_server:start_node(Name, peer, [{args,Args}]) of +	{error,Reason} -> +	    test_server:fail(Reason); +	{ok,Node} -> +	    ct:log("Node ~p started~n", [Node]), +	    Node +    end. +  unwritable(Fname) ->      {ok, Info} = file:read_file_info(Fname),      Mode = Info#file_info.mode - 8#00200, @@ -1014,7 +1093,7 @@ run_test(Config, Def, Pre) ->      XrlFile = filename:join(DataDir, DefFile),      ErlFile = filename:join(DataDir, Filename),      Opts = [return, warn_unused_vars,{outdir,DataDir}], -    ok = file:write_file(XrlFile, Def), +    ok = file:write_file(XrlFile, Def, [{encoding, unicode}]),      LOpts = [return, {report, false} |                case Pre of                   default ->  | 
