Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: run_tests.py

Issue 5090313282519040: Issue 517 - [Typed objects] Make unit tests compatible with Chrome and Safari (Closed)
Patch Set: Created May 19, 2014, 7:52 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .hgsubstate ('k') | test/common.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This file is part of Adblock Plus <http://adblockplus.org/>, 4 # This file is part of Adblock Plus <http://adblockplus.org/>,
5 # Copyright (C) 2006-2014 Eyeo GmbH 5 # Copyright (C) 2006-2014 Eyeo GmbH
6 # 6 #
7 # Adblock Plus is free software: you can redistribute it and/or modify 7 # Adblock Plus is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3 as 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
(...skipping 13 matching lines...) Expand all
24 app = flask.Flask(__name__) 24 app = flask.Flask(__name__)
25 25
26 def js_encode(str): 26 def js_encode(str):
27 return re.sub(r"(['\\])", r"\\\1", str) 27 return re.sub(r"(['\\])", r"\\\1", str)
28 28
29 @app.route("/<path:path>", methods = ["GET"]) 29 @app.route("/<path:path>", methods = ["GET"])
30 @app.route("/", methods = ["GET"]) 30 @app.route("/", methods = ["GET"])
31 def multiplex(path=""): 31 def multiplex(path=""):
32 request_url = urlparse(flask.request.url) 32 request_url = urlparse(flask.request.url)
33 request_path = request_url.path 33 request_path = request_url.path
34 if request_path.startswith("/lib/"): 34 islib = request_path.startswith("/lib/")
35 path = flask.safe_join(os.path.dirname(__file__), request_path.lstrip("/")) 35 backcompat = request_url.query == "backcompat"
36
37 rootdir = os.path.dirname(__file__)
38 if not islib:
39 rootdir = os.path.join("test")
40
41 if islib or backcompat:
42 path = flask.safe_join(rootdir, request_path.lstrip("/"))
36 if not os.path.isfile(path): 43 if not os.path.isfile(path):
37 return flask.abort(404) 44 return flask.abort(404)
38 45
39 with open(path, "rb") as file: 46 module = os.path.splitext(request_path[len("/lib/"):])[0]
40 module = os.path.splitext(request_path[len("/lib/"):])[0] 47 if backcompat:
41 data = "require.scopes['%s'] = function(){exports={};%s\nreturn exports;}( );" % (module, file.read()) 48 from jshydra.abp_rewrite import doRewrite
42 return (data, 200, {"Content-Type": "application/javascript; charset=utf-8 "}) 49 data = doRewrite([os.path.abspath(path)], ["module=true"] if islib else [] )
50 data = re.sub(r"require\.scopes\[.*?\]", "require.scopes['%s']" % module, data)
51 else:
52 with open(path, "rb") as file:
53 data = "require.scopes['%s'] = function(){var exports={};%s\nreturn expo rts;}();" % (module, file.read())
54 return (data, 200, {"Content-Type": "application/javascript; charset=utf-8"} )
43 else: 55 else:
44 if request_path.endswith("/"): 56 if request_path.endswith("/"):
45 request_path += "index.html" 57 request_path += "index.html"
46 return flask.send_from_directory(os.path.join(os.path.dirname(__file__), "te st"), request_path.lstrip("/")) 58 return flask.send_from_directory(rootdir, request_path.lstrip("/"))
47 59
48 if __name__ == "__main__": 60 if __name__ == "__main__":
49 app.run(debug=True) 61 app.run(debug=True)
OLDNEW
« no previous file with comments | « .hgsubstate ('k') | test/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld