aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-02-27 10:30:58 +0100
committerJohn Högberg <[email protected]>2018-02-27 10:32:00 +0100
commit3f79a3d1b490e829403529fd245ab8d5120d5e0e (patch)
treef2184fba9df1b5ff0a5df3c21144579186809219
parent7d8d1c67ec71fbf24b8659faf684fbdc7ab79378 (diff)
downloadotp-3f79a3d1b490e829403529fd245ab8d5120d5e0e.tar.gz
otp-3f79a3d1b490e829403529fd245ab8d5120d5e0e.tar.bz2
otp-3f79a3d1b490e829403529fd245ab8d5120d5e0e.zip
Make re_SUITE:sub_binaries less unstable
The small sub-binary conversion trick in the GC broke this test pretty often on some machines.
-rw-r--r--lib/stdlib/test/re_SUITE.erl15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/stdlib/test/re_SUITE.erl b/lib/stdlib/test/re_SUITE.erl
index 71f86e32e5..7b82647416 100644
--- a/lib/stdlib/test/re_SUITE.erl
+++ b/lib/stdlib/test/re_SUITE.erl
@@ -894,10 +894,13 @@ match_limit(Config) when is_list(Config) ->
%% Test that we get sub-binaries if subject is a binary and we capture
%% binaries.
sub_binaries(Config) when is_list(Config) ->
- Bin = list_to_binary(lists:seq(1,255)),
- {match,[B,C]}=re:run(Bin,"(a)",[{capture,all,binary}]),
- 255 = binary:referenced_byte_size(B),
- 255 = binary:referenced_byte_size(C),
- {match,[D]}=re:run(Bin,"(a)",[{capture,[1],binary}]),
- 255 = binary:referenced_byte_size(D),
+ %% The GC can auto-convert tiny sub-binaries to heap binaries, so we
+ %% extract large sequences to make the test more stable.
+ Bin = << <<I>> || I <- lists:seq(1, 4096) >>,
+ {match,[B,C]}=re:run(Bin,"a(.+)$",[{capture,all,binary}]),
+ true = byte_size(B) =/= byte_size(C),
+ 4096 = binary:referenced_byte_size(B),
+ 4096 = binary:referenced_byte_size(C),
+ {match,[D]}=re:run(Bin,"a(.+)$",[{capture,[1],binary}]),
+ 4096 = binary:referenced_byte_size(D),
ok.