Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 86 lines (77 sloc) 3.565 kb
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
1 #! /usr/bin/env escript
2 -mode(compile).
3 -include_lib("eunit/include/eunit.hrl").
4
5 test_fetching(Script, Package, Version) ->
6 Directory = test_server:temp_name("/tmp/agner"),
a8c80e9 @yrashk Some workarounds for bamboo tests so that they don't clash with their…
yrashk authored
7 os:cmd("rm -rf " ++ Directory),
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
8 filelib:ensure_dir(Directory ++ "/"),
9 Port = open_port({spawn,Script ++ " fetch " ++ Package ++ " -v " ++ Version},
10 [{cd, Directory},stream,use_stdio,stderr_to_stdout,
11 exit_status]),
12 PortHandler = fun (F,Acc) ->
13 receive
14 {'EXIT', Port, _} ->
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
15 {error, Acc};
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
16 {Port,{exit_status,0}} ->
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
17 {ok, Acc};
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
18 {Port,{exit_status,_}} ->
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
19 {error, Acc};
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
20 {Port,{data, Data}} ->
21 F(F, Acc ++ Data);
22 _ ->
23 F(F,Acc)
24 end
25 end,
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
26 ?assertMatch({ok,_}, PortHandler(PortHandler,[])),
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
27 os:cmd("rm -rf " ++ Directory).
28
29 test_building(Script, Package, Version) ->
30 Directory = test_server:temp_name("/tmp/agner"),
a8c80e9 @yrashk Some workarounds for bamboo tests so that they don't clash with their…
yrashk authored
31 os:cmd("rm -rf " ++ Directory),
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
32 filelib:ensure_dir(Directory ++ "/"),
33 Port = open_port({spawn,Script ++ " build " ++ Package ++ " -v " ++ Version},
34 [{cd, Directory},stream,use_stdio,stderr_to_stdout,
35 exit_status]),
36 PortHandler = fun (F,Acc) ->
37 receive
38 {'EXIT', Port, _} ->
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
39 {error, Acc};
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
40 {Port,{exit_status,0}} ->
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
41 {ok, Acc};
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
42 {Port,{exit_status,_}} ->
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
43 {error, Acc};
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
44 {Port,{data, Data}} ->
45 F(F, Acc ++ Data);
46 _ ->
47 F(F,Acc)
48 end
49 end,
81ec4f6 @yrashk Include agner output into test results in bamboo_test
yrashk authored
50 ?assertMatch({ok,_}, PortHandler(PortHandler,[])),
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
51 os:cmd("rm -rf " ++ Directory).
52
53 tests_version_(Script, Package, Version) ->
a8c80e9 @yrashk Some workarounds for bamboo tests so that they don't clash with their…
yrashk authored
54 {inorder,
55 [
56 {"Fetching " ++ Package ++ " version " ++ Version ,
57 {timeout, 60*15,
58 fun () ->
59 test_fetching(Script, Package, Version)
60 end}},
61 {"Building " ++ Package ++ " version " ++ Version ,
62 {timeout, 60*15,
63 fun () ->
64 test_building(Script, Package, Version)
65 end}}]}.
b2dfa45 @yrashk Added initial version of Bamboo integration script for packages
yrashk authored
66
67
68
69 tests_(Script, Package) ->
70 Versions = string:tokens(os:cmd(Script ++ " versions " ++ Package),[$\n]),
71 lists:map(fun (Version) ->
72 {Package ++ " version " ++ Version, {generator, fun () -> tests_version_(Script, Package, Version) end}}
73 end, Versions).
74
75
76 main([]) ->
77 eunit:start(),
78 Script = filename:absname(filename:join([filename:dirname(code:which(?MODULE)), "..", "agner"])),
79 Packages = string:tokens(os:cmd(Script ++ " list"),[$\n]),
80 lists:foreach(fun(Package) ->
81 eunit:test([{Package, {generator, fun () ->
82 tests_(Script,Package)
83 end}}], [{report,{eunit_surefire,[{dir,"."}]}}])
84 end, Packages),
85 eunit:stop().
Something went wrong with that request. Please try again.