| 1 | -module (directory_tester_test). |
|---|
| 2 | -test (exports). |
|---|
| 3 | -export ([slave_node/0]). |
|---|
| 4 | -export ([slave_node_nonode/0]). |
|---|
| 5 | -export ([read_args/0]). |
|---|
| 6 | |
|---|
| 7 | slave_node () -> |
|---|
| 8 | Result = directory_tester: slave_node (mynode@myhost), |
|---|
| 9 | {myhost, mynode_extremeforge_slave} = Result. |
|---|
| 10 | |
|---|
| 11 | slave_node_nonode () -> |
|---|
| 12 | not_alive = directory_tester: slave_node (nonode@nohost). |
|---|
| 13 | |
|---|
| 14 | read_args () -> |
|---|
| 15 | Tree = [{directory, "toto", []}, |
|---|
| 16 | {directory, "titi", []}], |
|---|
| 17 | fixtures: use_tree (Tree, fun read_args_dirs/2), |
|---|
| 18 | fixtures: use_tree (Tree, fun read_args_paths/2), |
|---|
| 19 | fixtures: use_tree (Tree, fun read_args_with_slave/2). |
|---|
| 20 | |
|---|
| 21 | read_args_dirs (Dir, _) -> |
|---|
| 22 | [Toto, Titi] = [filename: join (Dir, T) || T <- ["toto", "titi"]], |
|---|
| 23 | Tests = [{[Toto], {[Toto], []}}, |
|---|
| 24 | {[Toto, Titi], {[Toto], [{compiler, [{i, Titi}]}]}}], |
|---|
| 25 | lists: foldl (fun read_args_test/2, 1, Tests). |
|---|
| 26 | |
|---|
| 27 | read_args_paths (Dir, _) -> |
|---|
| 28 | [Toto, Titi] = [filename: join (Dir, T) || T <- ["toto", "titi"]], |
|---|
| 29 | Titi_toto = Titi ++ ":" ++ Toto, |
|---|
| 30 | Tests = [{[Titi_toto], |
|---|
| 31 | {[Titi, Toto], []}}, |
|---|
| 32 | {[Titi_toto, Titi_toto], |
|---|
| 33 | {[Titi, Toto], [{compiler, [{i, Titi}, {i, Toto}]}]}}], |
|---|
| 34 | lists: foldl (fun read_args_test/2, 1, Tests). |
|---|
| 35 | |
|---|
| 36 | read_args_with_slave (Dir, _) -> |
|---|
| 37 | [Toto, Titi] = [filename: join (Dir, T) || T <- ["toto", "titi"]], |
|---|
| 38 | Slave_args = "-pa /foo/bar -mnesia_dir /var/mnesia", |
|---|
| 39 | Args = [Toto, Titi, Slave_args], |
|---|
| 40 | {[Toto], Options} = directory_tester: read_args (Args), |
|---|
| 41 | [{i, Titi}] = proplists: get_value (compiler, Options), |
|---|
| 42 | Slave_args = proplists: get_value (slave, Options). |
|---|
| 43 | |
|---|
| 44 | read_args_test ({In, Out}, Count) -> |
|---|
| 45 | {Count, In, Out} = {Count, In, directory_tester: read_args (In)}, |
|---|
| 46 | Count + 1. |
|---|