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

Unified Diff: tests/standalone/io/file_test.dart

Issue 899243002: Make standalone tests not dependent on current working directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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: tests/standalone/io/file_test.dart
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index 0ce18aeabb4b0e494bfed255c8f316741442f8ab..633fe3866d708a78d7571a95e5abeba40e7f7393 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -969,7 +969,7 @@ class FileTest {
f.readAsString(encoding: UTF8).then((text) {
Expect.isTrue(text.endsWith("42 bytes."));
Expect.equals(42, text.length);
- var name = getDataFilename("tests/standalone/io/read_as_text.dat");
+ var name = getFilename("tests/standalone/io/read_as_text.dat");
var f = new File(name);
f.readAsString(encoding: UTF8).then((text) {
Expect.equals(6, text.length);
@@ -1006,7 +1006,7 @@ class FileTest {
var text = new File(name).readAsStringSync();
Expect.isTrue(text.endsWith("42 bytes."));
Expect.equals(42, text.length);
- name = getDataFilename("tests/standalone/io/read_as_text.dat");
+ name = getFilename("tests/standalone/io/read_as_text.dat");
text = new File(name).readAsStringSync();
Expect.equals(6, text.length);
var expected = [955, 120, 46, 32, 120, 10];
@@ -1054,7 +1054,7 @@ class FileTest {
var line = lines[0];
Expect.isTrue(line.endsWith("42 bytes."));
Expect.equals(42, line.length);
- name = getDataFilename("tests/standalone/io/readline_test1.dat");
+ name = getFilename("tests/standalone/io/readline_test1.dat");
lines = new File(name).readAsLinesSync();
Expect.equals(10, lines.length);
}
@@ -1274,11 +1274,12 @@ class FileTest {
// Helper method to be able to run the test from the runtime
// directory, or the top directory.
- static String getFilename(String path) =>
- new File(path).existsSync() ? path : 'runtime/$path';
-
- static String getDataFilename(String path) =>
- new File(path).existsSync() ? path : '../$path';
+ static String getFilename(String path) {
+ var testPath = Platform.script.resolve('../../../$path');
+ return new File.fromUri(testPath).existsSync()
+ ? testPath.toFilePath()
+ : Platform.script.resolve('../../../runtime/$path').toFilePath();
+ }
// Main test entrypoint.
static testMain() {

Powered by Google App Engine
This is Rietveld 408576698