summaryrefslogtreecommitdiff
path: root/lib/stdlib
diff options
context:
space:
mode:
authorDan Gudmundsson <dgud@erlang.org>2023-03-02 16:12:48 +0100
committerDan Gudmundsson <dgud@erlang.org>2023-03-06 14:58:01 +0100
commitb56ee2f1aec82193cc47e897ae650b014d2dabb7 (patch)
tree9f5f02d3fe407e4bcd633a8fb100787e53f0c9f9 /lib/stdlib
parent4e15bb2cdd8d7e854052efdb1c0263853b9f13f9 (diff)
downloaderlang-b56ee2f1aec82193cc47e897ae650b014d2dabb7.tar.gz
Update script to take 'update_tests' argument
Make it possible to update the binary testfile when updating version.
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/uc_spec/README-UPDATE.txt7
-rw-r--r--lib/stdlib/uc_spec/gen_unicode_mod.escript32
2 files changed, 28 insertions, 11 deletions
diff --git a/lib/stdlib/uc_spec/README-UPDATE.txt b/lib/stdlib/uc_spec/README-UPDATE.txt
index 8af7b54a07..42ca52b987 100644
--- a/lib/stdlib/uc_spec/README-UPDATE.txt
+++ b/lib/stdlib/uc_spec/README-UPDATE.txt
@@ -35,7 +35,12 @@ this very same file (lib/stdlib/uc_spec/README-UPDATE.txt).
Remember to update these instructions if a new file is added or any other change
is required for future version updates.
-6. Run the test for the Unicode suite from the OTP repository root dir.
+6. Check if the test file needs to be updated:
+ (cd $ERL_TOP/lib/stdlib/uc_spec; escript gen_unicode_mod.escript update_tests)
+ If ../test/unicode_util_SUITE_data/unicode_table.bin is updated include it in
+ the commit.
+
+7. Run the test for the Unicode suite from the OTP repository root dir.
$ export ERL_TOP=$PWD
$ export PATH=$ERL_TOP/bin:$PATH
$ ./otp_build all -a && ./otp_build tests
diff --git a/lib/stdlib/uc_spec/gen_unicode_mod.escript b/lib/stdlib/uc_spec/gen_unicode_mod.escript
index 6f55f6da45..d0a2974601 100644
--- a/lib/stdlib/uc_spec/gen_unicode_mod.escript
+++ b/lib/stdlib/uc_spec/gen_unicode_mod.escript
@@ -26,7 +26,7 @@
-record(cp, {name, class, dec, comp, cs, cat}).
-define(MOD, "unicode_util").
-main(_) ->
+main(Args) ->
%% Parse main table
UD = file_open("../uc_spec/UnicodeData.txt"),
Data0 = foldl(fun parse_unicode_data/2, [], UD),
@@ -66,8 +66,13 @@ main(_) ->
ok = file:close(WidthF),
%% Make module
+ UpdateTests = case Args of
+ ["update_tests"] -> true;
+ _ -> false
+ end,
+
{ok, Out} = file:open(?MOD++".erl", [write]),
- gen_file(Out, Data, ExclData, maps:from_list(Props), WideCs),
+ gen_file(Out, Data, ExclData, maps:from_list(Props), WideCs, UpdateTests),
ok = file:close(Out),
ok.
@@ -216,7 +221,7 @@ is_default_width(Index, WD) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-gen_file(Fd, Data, ExclData, Props, WideCs) ->
+gen_file(Fd, Data, ExclData, Props, WideCs, UpdateTests) ->
gen_header(Fd),
gen_static(Fd),
gen_norm(Fd),
@@ -225,7 +230,7 @@ gen_file(Fd, Data, ExclData, Props, WideCs) ->
gen_gc(Fd, Props),
gen_compose_pairs(Fd, ExclData, Data),
gen_case_table(Fd, Data),
- gen_unicode_table(Fd, Data),
+ gen_unicode_table(Fd, Data, UpdateTests),
gen_width_table(Fd, WideCs),
ok.
@@ -929,7 +934,7 @@ case_data(_, _) ->
def_cp([], CP) -> CP;
def_cp(CP, _) -> CP.
-gen_unicode_table(Fd, Data) ->
+gen_unicode_table(Fd, Data, UpdateTests) ->
FixCanon = fun(_, #cp{class=CCC, dec=Dec, comp=Comp, cat=Cat}) ->
Canon = decompose(Dec,Data),
#{ccc=>CCC, canonical=>Canon, compat=>Comp, cat=>Cat}
@@ -948,11 +953,18 @@ gen_unicode_table(Fd, Data) ->
end, Dict0),
%% Export testfile
- %% Dict1 = lists:map(fun({Id,{CCC, Canon, Compat, Cat}}) ->
- %% {_, ECat} = lists:keyfind(Cat, 1, category_translate()),
- %% {Id, {CCC, Canon, Compat, ECat}}
- %% end, Dict0),
- %% file:write_file("../test/unicode_util_SUITE_data/unicode_table.bin", term_to_binary(Dict1, [compressed])),
+ case UpdateTests of
+ true ->
+ Dict1 = lists:map(fun({Id,{CCC, Canon, Compat, Cat}}) ->
+ {_, ECat} = lists:keyfind(Cat, 1, category_translate()),
+ {Id, {CCC, Canon, Compat, ECat}}
+ end, Dict0),
+ TestFile = "../test/unicode_util_SUITE_data/unicode_table.bin",
+ io:format("Updating: ~s~n", [TestFile]),
+ file:write_file(TestFile, term_to_binary(Dict1, [compressed]));
+ false ->
+ ignore
+ end,
[io:format(Fd, "unicode_table(~w) -> ~w;~n", [CP, Map]) || {CP,Map} <- NonDef],
io:format(Fd, "unicode_table(_) -> ~w.~n~n",[Def]),