Common-Test may try to create directory names that are longer than system limit
Describe the bug When running a test specification that selects only certain tests to run, CT will create a separate directory per test, and the name of the directory seems to be a concatenation of:
- The two last directories of the suite path
- The suite name
- The word "groups"
- The name of the testcase
- The word "logs"
The problem is that, e.g., on Linux there is a 255 byte limit for filenames and it is not hard to end up going over that limit (e.g. suite-name and testcase name of 60 chars each is not unheard of), in which case CT fails. Instead, CT should truncate and/or use a hash.
buck2's test-runner uses this internally to run CT tests, so it is particularly affected
To Reproduce
$ cat fails.spec
{groups,"/tmp/some_directory_with_a_quite_very_long_name/another_directory_that_just_happened_to_also_have_an_unusually_long_name",
it_is_not_surprising_that_now_we_also_get_another_long_name_in_the_SUITE,
[[my_group]],
{cases,[test_with_a_name_that_is_descriptive_which_is_nice_but_alas_now_too_long]}
}.
{ct_hooks,[]}.
{auto_compile,true}.
{logdir,"/tmp/some_directory_with_a_quite_very_long_name/another_directory_that_just_happened_to_also_have_an_unusually_long_name/logs"}.
$ cat it_is_not_surprising_that_now_we_also_get_another_long_name_in_the_SUITE.erl
module(it_is_not_surprising_that_now_we_also_get_another_long_name_in_the_SUITE).
-export([
all/0,
groups/0,
test_with_a_name_that_is_descriptive_which_is_nice_but_alas_now_too_long/1
]).
all() ->
[ {group, my_group} ].
groups() ->
[
{my_group, [], [ test_with_a_name_that_is_descriptive_which_is_nice_but_alas_now_too_long ]}
].
test_with_a_name_that_is_descriptive_which_is_nice_but_alas_now_too_long(_Config) ->
ok.
$ ct_run -spec fails.spec
Erlang/OTP 25 [erts-13.1.5] [source-5a804b540d] [64-bit] [smp:36:36] [ds:36:36:10] [async-threads:1] [jit:ns] [systemtap]
Common Test v1.23.3 starting (cwd is /tmp/some_directory_with_a_quite_very_long_name/another_directory_that_just_happened_to_also_have_an_unusually_long_name)
Eshell V13.1.5 (abort with ^G)
(ct@80108)1>
Common Test: Running make in test directories...
CWD set to: "/tmp/some_directory_with_a_quite_very_long_name/another_directory_that_just_happened_to_also_have_an_unusually_long_name/logs/[email protected]_10.39.43"
TEST INFO: 1 test(s), 1 case(s) in 1 suite(s)
EXIT, reason {cannot_create_log_dir,{{error,enametoolong},
"/tmp/some_directory_with_a_quite_very_long_name/another_directory_that_just_happened_to_also_have_an_unusually_long_name/logs/[email protected]_10.39.43/some_directory_with_a_quite_very_long_name.another_directory_that_just_happened_to_also_have_an_unusually_long_name.it_is_not_surprising_that_now_we_also_get_another_long_name_in_the_SUITE.groups.test_with_a_name_that_is_descriptive_which_is_nice_but_alas_now_too_long.logs"}}}}},
...
Expected behavior CT runs the specified tests without problems, just like when running the whole suite
Affected versions Tried it on OTP 25, I suppose older versions are affected as well
thanks for the report. we need to schedule fixing that for a bit later due to priorities :-(