Commits

Anonymous committed 43b9379

Adding support for specifying multiple config files for a single run

Comments (0)

Files changed (2)

 %% ====================================================================
 
 main([]) ->
-    io:format("Usage: basho_bench CONFIG_FILE~n");
+    io:format("Usage: basho_bench CONFIG_FILE ..~n");
 
-main([Config]) ->
-    %% Load baseline config
+main(Configs) ->
+    %% Load baseline configs
     ok = application:load(basho_bench),
 
-    %% Load the config file
-    basho_bench_config:load(Config),
+    %% Load the config files
+    basho_bench_config:load(Configs),
 
     %% Init code path
     add_code_paths(basho_bench_config:get(code_paths, [])),
     [] = os:cmd(?FMT("rm -f ~s; ln -sf ~s ~s", [TestLink, TestDir, TestLink])),
 
     %% Copy the config into the test dir for posterity
-    {ok, _} = file:copy(Config, filename:join(TestDir, filename:basename(Config))),
+    [ begin {ok, _} = file:copy(Config, filename:join(TestDir, filename:basename(Config))) end
+      || Config <- Configs ],
 
     %% Set our CWD to the test dir
     ok = file:set_cwd(TestDir),

src/basho_bench_config.erl

 %% Public API
 %% ===================================================================
 
-load(File) ->
-    case file:consult(File) of
-        {ok, Terms} ->
-            load_config(Terms);
-        {error, Reason} ->
-            ?FAIL_MSG("Failed to parse config file ~s: ~p\n", [File, Reason])
-    end.
+load(Files) ->
+    TermsList =
+        [ case file:consult(File) of
+              {ok, Terms} ->
+                  Terms;
+              {error, Reason} ->
+                  ?FAIL_MSG("Failed to parse config file ~s: ~p\n", [File, Reason])
+          end || File <- Files ],
+    load_config(lists:append(TermsList)).
 
 set(Key, Value) ->
     ok = application:set_env(basho_bench, Key, Value).
-    
+
 get(Key) ->
     case application:get_env(basho_bench, Key) of
         {ok, Value} ->