9 here
= os
.path
.abspath(os
.path
.dirname(__file__
))
11 local_requirements
= {
12 "mozinfo": "testing/mozbase/mozinfo",
13 "mozlog": "testing/mozbase/mozlog",
14 "mozdebug": "testing/mozbase/mozdebug",
15 "marionette_driver": "testing/marionette/client/",
16 "mozprofile": "testing/mozbase/mozprofile",
17 "mozprocess": "testing/mozbase/mozprocess",
18 "mozcrash": "testing/mozbase/mozcrash",
19 "mozrunner": "testing/mozbase/mozrunner",
20 "mozleak": "testing/mozbase/mozleak",
21 "mozversion": "testing/mozbase/mozversion",
24 requirements_re
= re
.compile(r
"(%s)[^\w]" % "|".join(local_requirements
.keys()))
27 class ReplaceRequirements(object):
28 def __init__(self
, top_src_path
, tox_path
):
29 self
.top_src_path
= top_src_path
30 self
.tox_path
= tox_path
35 deps
= self
.read_deps()
37 self
.replace_path(dep
)
39 def __exit__(self
, *args
, **kwargs
):
40 for path
, data
in self
.file_cache
.iteritems():
41 with
open(path
, "wb") as f
:
46 parser
= ConfigParser
.ConfigParser()
47 path
= os
.path
.join(self
.tox_path
, "tox.ini")
50 deps
= parser
.get("testenv", "deps")
51 dep_re
= re
.compile("(?:.*:\s*)?-r(.*)")
53 # This can break if we start using more features of tox
54 for dep
in deps
.splitlines():
57 rv
.append(m
.group(1).replace("{toxinidir}", self
.tox_path
))
60 def replace_path(self
, requirements_path
):
62 with
open(requirements_path
, "rb") as f
:
63 self
.file_cache
[requirements_path
] = f
.read()
66 m
= requirements_re
.match(line
)
71 path
= local_requirements
[key
]
72 lines
.append("-e %s\n" % (os
.path
.join(self
.top_src_path
, path
),))
74 with
open(requirements_path
, "wb") as f
:
76 f
.write(line
.encode("utf8"))
78 with
open(requirements_path
, "rb") as f
:
83 parser
= argparse
.ArgumentParser()
84 parser
.add_argument("--no-tools", dest
="tools", action
="store_false",
85 default
=True, help="Don't run the tools unittests")
86 parser
.add_argument("--no-wptrunner", dest
="wptrunner", action
="store_false",
87 default
=True, help="Don't run the wptrunner unittests")
88 parser
.add_argument("tox_kwargs", nargs
=argparse
.REMAINDER
,
89 help="Arguments to pass through to tox")
93 def run(top_src_dir
, tools
=True, wptrunner
=True, tox_kwargs
=None, **kwargs
):
95 if tox_kwargs
is None:
98 tox_paths
.append(os
.path
.join(top_src_dir
,
104 tox_paths
.append(os
.path
.join(top_src_dir
,
113 for tox_path
in tox_paths
:
114 with
ReplaceRequirements(top_src_dir
, tox_path
):
115 cmd
= ["tox"] + tox_kwargs
117 subprocess
.check_call(cmd
, cwd
=tox_path
)
118 except subprocess
.CalledProcessError
:
124 kwargs
= vars(get_parser().parse_args())
125 top_src_path
= os
.path
.abspath(os
.path
.join(here
, os
.pardir
, os
.pardir
))
126 return run(top_src_path
, **kwargs
)
129 if __name__
== "__main__":