7 LONG_OPTIONS
= ["shard=", "shards="]
8 BASE_COMMAND
= "./configure --enable-internal-stats --enable-experimental"
10 def RunCommand(command
):
11 run
= subprocess
.Popen(command
, shell
=True)
12 output
= run
.communicate()
14 print "Non-zero return code: " + str(run
.returncode
) + " => exiting!"
17 def list_of_experiments():
19 configure_file
= open("configure")
21 for line
in configure_file
.read().split("\n"):
22 if line
== 'EXPERIMENT_LIST="':
27 currently_broken
= ["csm"]
29 if experiment
not in currently_broken
:
30 experiments
.append(experiment
)
35 options
= {"--shard": 0, "--shards": 1}
37 opt_end_index
= argv
.index("--")
39 opt_end_index
= len(argv
)
41 o
, _
= getopt
.getopt(argv
[1:opt_end_index
], None, LONG_OPTIONS
)
42 except getopt
.GetoptError
, err
:
44 print "Usage: %s [--shard=<n> --shards=<n>] -- [configure flag ...]"%argv
[0]
48 extra_args
= argv
[opt_end_index
+ 1:]
50 # Shard experiment list
51 shard
= int(options
["--shard"])
52 shards
= int(options
["--shards"])
53 experiments
= list_of_experiments()
54 base_command
= " ".join([BASE_COMMAND
] + extra_args
)
55 configs
= [base_command
]
56 configs
+= ["%s --enable-%s" % (base_command
, e
) for e
in experiments
]
57 my_configs
= zip(configs
, range(len(configs
)))
58 my_configs
= filter(lambda x
: x
[1] % shards
== shard
, my_configs
)
59 my_configs
= [e
[0] for e
in my_configs
]
61 # Run configs for this shard
62 for config
in my_configs
:
65 def test_build(configure_command
):
66 print "\033[34m\033[47mTesting %s\033[0m" % (configure_command
)
67 RunCommand(configure_command
)
68 RunCommand("make clean")
71 if __name__
== "__main__":