diff options
author | Siri Hansen <siri@erlang.org> | 2016-12-09 14:33:43 +0100 |
---|---|---|
committer | Siri Hansen <siri@erlang.org> | 2016-12-09 14:49:48 +0100 |
commit | e427a835301c41a1403cf6b9e6c363ceae3e781c (patch) | |
tree | bf61e4f2cee158c7429f760630eadc57a5b663a8 /test | |
parent | a0e7ff2eb95a8093f666d310bd5df6395a243bd8 (diff) |
Translate path to testspec
This is a bugfix. It makes sure that the given path to a testspec is
translated so common_test will pick the spec from the _build
directory, and not from the source tree.
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_ct_SUITE.erl | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl index d913748..6339e6b 100644 --- a/test/rebar_ct_SUITE.erl +++ b/test/rebar_ct_SUITE.erl @@ -1248,10 +1248,10 @@ testspec(Config) -> rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), Spec1 = filename:join([AppDir, "test", "some.spec"]), ok = filelib:ensure_dir(Spec1), - ok = file:write_file(Spec1, "[].\n"), + ok = file:write_file(Spec1, "{suites,\".\",all}.\n"), Spec2 = filename:join([AppDir, "specs", "another.spec"]), ok = filelib:ensure_dir(Spec2), - ok = file:write_file(Spec2, "[].\n"), + ok = file:write_file(Spec2, "{suites,\"../test/\",all}.\n"), {ok,Wd} = file:get_cwd(), ok = file:set_cwd(AppDir), @@ -1266,23 +1266,42 @@ testspec(Config) -> CommandProvider = providers:get_provider(ct, Providers, Namespace), GetOptSpec = providers:opts(CommandProvider), + %% Testspec in "test" directory {ok, GetOptResult1} = getopt:parse(GetOptSpec, ["--spec","test/some.spec"]), State1 = rebar_state:command_parsed_args(State, GetOptResult1), Tests1 = rebar_prv_common_test:prepare_tests(State1), {ok, NewState1} = rebar_prv_common_test:compile(State1, Tests1), + {ok, T1} = Tests1, + Opts1= rebar_prv_common_test:translate_paths(NewState1, T1), + + %% check thath extra src dir is added [App1] = rebar_state:project_apps(NewState1), ["test"] = rebar_dir:extra_src_dirs(rebar_app_info:opts(App1)), + %% check that path is translated + ExpectedSpec1 = filename:join([AppDir, "_build", "test", "lib", Name, + "test", "some.spec"]), + [ExpectedSpec1] = proplists:get_value(spec, Opts1), + + + %% Testspec in directory other than "test" {ok, GetOptResult2} = getopt:parse(GetOptSpec, ["--spec","specs/another.spec"]), State2 = rebar_state:command_parsed_args(State, GetOptResult2), - Tests2 = rebar_prv_common_test:prepare_tests(State2), - {ok, NewState2} = rebar_prv_common_test:compile(State1, Tests2), + Tests2 = {ok, T2} =rebar_prv_common_test:prepare_tests(State2), + {ok, NewState2} = rebar_prv_common_test:compile(State2, Tests2), + Opts2= rebar_prv_common_test:translate_paths(NewState2, T2), + %% check thath extra src dirs are added [App2] = rebar_state:project_apps(NewState2), ["specs","test"] = lists:sort(rebar_dir:extra_src_dirs(rebar_app_info:opts(App2))), + %% check that paths are translated + ExpectedSpec2 = filename:join([AppDir, "_build", "test", "lib", Name, + "specs", "another.spec"]), + [ExpectedSpec2] = proplists:get_value(spec, Opts2), + ok = file:set_cwd(Wd), ok. |