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

Side by Side Diff: tests/standalone/io/file_input_stream_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Testing file input stream, VM-only, standalone test. 4 // Testing file input stream, VM-only, standalone test.
5 5
6 import "dart:convert"; 6 import "dart:convert";
7 import "dart:io"; 7 import "dart:io";
8 8
9 import "package:async_helper/async_helper.dart"; 9 import "package:async_helper/async_helper.dart";
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 11
12 // Helper method to be able to run the test from the runtime 12 // Helper method to be able to run the test from the runtime
13 // directory, or the top directory. 13 // directory, or the top directory.
14 String getFilename(String path) => 14 String getFilename(String path) {
15 new File(path).existsSync() ? path : '../$path'; 15 var testPath = Platform.script.resolve('../../../$path');
16 return new File.fromUri(testPath).existsSync()
17 ? testPath.toFilePath()
18 : Platform.script.resolve('../../../runtime/$path').toFilePath();
19 }
16 20
17 void testStringLineSplitter() { 21 void testStringLineSplitter() {
18 String fileName = getFilename("tests/standalone/io/readuntil_test.dat"); 22 String fileName = getFilename("tests/standalone/io/readuntil_test.dat");
19 // File contains "Hello Dart\nwassup!\n" 23 // File contains "Hello Dart\nwassup!\n"
20 File file = new File(fileName); 24 File file = new File(fileName);
21 int linesRead = 0; 25 int linesRead = 0;
22 var lineStream = file.openRead() 26 var lineStream = file.openRead()
23 .transform(UTF8.decoder) 27 .transform(UTF8.decoder)
24 .transform(new LineSplitter()); 28 .transform(new LineSplitter());
25 lineStream.listen((line) { 29 lineStream.listen((line) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 testInputStreamDelete(); 263 testInputStreamDelete();
260 testInputStreamAppend(); 264 testInputStreamAppend();
261 testInputStreamOffset(); 265 testInputStreamOffset();
262 testInputStreamBadOffset(); 266 testInputStreamBadOffset();
263 // Check the length of these files as both are text files where one 267 // Check the length of these files as both are text files where one
264 // is without a terminating line separator which can easily be added 268 // is without a terminating line separator which can easily be added
265 // back if accidentally opened in a text editor. 269 // back if accidentally opened in a text editor.
266 testStringLineSplitterEnding("readline_test1.dat", 111); 270 testStringLineSplitterEnding("readline_test1.dat", 111);
267 testStringLineSplitterEnding("readline_test2.dat", 114); 271 testStringLineSplitterEnding("readline_test2.dat", 114);
268 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698