Chromium Code Reviews| Index: tools/testing/dart/http_server.dart |
| =================================================================== |
| --- tools/testing/dart/http_server.dart (revision 17743) |
| +++ tools/testing/dart/http_server.dart (working copy) |
| @@ -39,10 +39,11 @@ |
| .join(new Path('../../test.dart')) |
| .canonicalize() |
| .toNativePath(); |
| - TestingServerRunner.setPackageRootDir({'mode': args['mode'], |
| - 'arch': args['arch'], 'system': Platform.operatingSystem, |
| - 'build_directory': ''}); |
| - |
| + var conf = {'mode': args['mode'], |
| + 'arch': args['arch'], 'system': Platform.operatingSystem, |
| + 'build_directory': ''}; |
| + TestingServerRunner.setPackageRootDir(conf); |
| + TestingServerRunner.setBuildDir(conf); |
| TestingServerRunner.startHttpServer('127.0.0.1', |
| port: int.parse(args['port'])); |
| print('Server listening on port ' |
| @@ -61,16 +62,24 @@ |
| class TestingServerRunner { |
| static List serverList = []; |
| static Path _packageRootDir = null; |
| + static Path _buildDirectory = null; |
| // Added as a getter so that the function will be called again each time the |
| // default request handler closure is executed. |
| static Path get packageRootDir => _packageRootDir; |
| + static Path get buildDirectory => _buildDirectory; |
| static setPackageRootDir(Map configuration) { |
| _packageRootDir = TestUtils.currentWorkingDirectory.join( |
| new Path(TestUtils.buildDir(configuration))); |
| + print(_packageRootDir); |
|
kustermann
2013/01/29 12:29:30
Why are these "print()"'s here?
In case we wanna
ricow1
2013/01/30 14:38:42
left over debug info, removed
|
| } |
| + static setBuildDir(Map configuration) { |
| + _buildDirectory = new Path(TestUtils.buildDir(configuration)); |
| + print(_buildDirectory); |
| + } |
| + |
| static startHttpServer(String host, {int allowedPort:-1, int port: 0}) { |
| var basePath = TestUtils.dartDir(); |
| var httpServer = new HttpServer(); |
| @@ -81,9 +90,17 @@ |
| }; |
| httpServer.defaultRequestHandler = (request, resp) { |
| var requestPath = new Path(request.path.substring(1)).canonicalize(); |
| + if (requestPath.toString().startsWith("tests/html/xhr")) print(requestPath); |
|
kustermann
2013/01/29 12:29:30
long line -- finally I can complain about this as
ricow1
2013/01/30 14:38:42
Removed
|
| var path = basePath.join(requestPath); |
| var file = new File(path.toNativePath()); |
| - |
| + // Since the build directory may not be located directly beneath the dart |
| + // root directory (if we pass it in, e.g., for dartium testing) we serve |
| + // files from the build directory explicitly. Please note that if |
| + // buildDirectory has the same name as a directory inside the dart repo |
| + // we will server files from the buildDirectory. |
| + if (path.toString().startsWith(buildDirectory.toString())) { |
| + file = new File(path.toNativePath()); |
| + } |
| if (requestPath.segments().contains(packagesDirName)) { |
| // Essentially implement the packages path rewriting, so we don't have |
| // to pass environment variables to the browsers. |