Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: tools/testing/dart/http_server.dart

Issue 12183022: Change the location of the output directory of generated tests to be inside build directory, but no… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/testing/dart/http_server.dart
diff --git a/tools/testing/dart/http_server.dart b/tools/testing/dart/http_server.dart
index 84a5b771913bb4f090f67243b8ed16cb8aca00e3..6966ab3fcf88f0925011bfe37b52070baad597e7 100644
--- a/tools/testing/dart/http_server.dart
+++ b/tools/testing/dart/http_server.dart
@@ -40,7 +40,11 @@ main() {
.join(new Path('../../test.dart'))
.canonicalize()
.toNativePath();
+ // Note: args['package-root'] is always the build directory. We have the
+ // implicit assumption that it contains the 'packages' subdirectory.
+ // TODO: We should probably rename 'package-root' to 'build-directory'.
TestingServerRunner._packageRootDir = new Path(args['package-root']);
+ TestingServerRunner._buildDirectory = new Path(args['package-root']);
TestingServerRunner.startHttpServer('127.0.0.1',
port: int.parse(args['port']));
print('Server listening on port '
@@ -59,16 +63,22 @@ main() {
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)));
}
+ static setBuildDir(Map configuration) {
+ _buildDirectory = new Path(TestUtils.buildDir(configuration));
+ }
+
static startHttpServer(String host, {int allowedPort:-1, int port: 0}) {
var basePath = TestUtils.dartDir();
var httpServer = new HttpServer();
@@ -78,10 +88,23 @@ class TestingServerRunner {
print('Test http server error: $e');
};
httpServer.defaultRequestHandler = (request, resp) {
+ // TODO(kustermann,ricow): We could change this to the following scheme:
+ // http://host:port/root_dart/X -> $DartDir/X
+ // http://host:port/root_build/X -> $BuildDir/X
+ // http://host:port/root_packages/X -> $BuildDir/packages/X
+ // Issue: 8368
+
var requestPath = new Path(request.path.substring(1)).canonicalize();
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 (requestPath.toString().startsWith(buildDirectory.toString())) {
Emily Fortuna 2013/02/07 23:37:47 This doesn't work because requestPath isn't an abs
kustermann 2013/02/08 01:55:13 It "sort of" works because this code assumes that
+ file = new File(requestPath.toNativePath());
+ }
if (requestPath.segments().contains(packagesDirName)) {
// Essentially implement the packages path rewriting, so we don't have
// to pass environment variables to the browsers.

Powered by Google App Engine
This is Rietveld 408576698