anchor.diff:                        %% combine `erl_first_files` and `common_test_first_files` and
                         %% adjust compile opts to include `common_test_compile_opts`
                         %% and `{src_dirs, "test"}`
  -                      TestState = first_files(test_opts(S, InDir, OutDir)),
  +                      TestState = test_state(S, InDirs, OutDir),
                         ok = rebar_erlc_compiler:compile(TestState, AppDir)
                     end, ProjectApps),
       Path = code:get_path(),
       true = code:add_patha(OutDir),
  -    CTOpts = resolve_ct_opts(State, Opts),
  -    Result = handle_results(ct:run_test([{dir, OutDir}] ++ CTOpts)),
  +    CTOpts = resolve_ct_opts(State, Opts, OutDir),
  +    Result = handle_results(ct:run_test(CTOpts)),
       true = code:set_path(Path),
       case Result of
           {error, Reason} ->
  
positive.code:     "";
  help(userconfig) ->
      "".
  
  transform_opts(Opts) ->
      transform_opts(Opts, []).
  
negative.code:     end,
      ensure_dir(Rest).
  
  test_state(State, InDirs, OutDir) ->
      ErlOpts = rebar_state:get(State, common_test_compile_opts, []) ++
                rebar_utils:erl_opts(State),
      TestOpts = [{outdir, OutDir}] ++
                 [{src_dirs, ["src", "test"] ++ InDirs}] ++
                 ErlOpts,
      first_files(rebar_state:set(State, erl_opts, TestOpts)).
  
  first_files(State) ->
      BaseFirst = rebar_state:get(State, erl_first_files, []),
      CTFirst = rebar_state:get(State, common_test_first_files, []),
      rebar_state:set(State, erl_first_modules, BaseFirst ++ CTFirst).
  
  resolve_ct_opts(State, CmdLineOpts, OutDir) ->
      CTOpts = rebar_state:get(State, common_test_opts, []),
      Opts = lists:ukeymerge(1,
                      lists:ukeysort(1, CmdLineOpts),
                      lists:ukeysort(1, CTOpts)),
      %% rebar has seperate input and output directories whereas `common_test`
      %% uses only a single directory so set `dir` to our precompiled `OutDir`
      %% and disable `auto_compile`
      [{auto_compile, false}, {dir, OutDir}] ++ lists:keydelete(dir, 1, Opts).
  
  handle_results([Result]) ->
      handle_results(Result);
  