@@ -74,10 +74,8 @@ class FileTest {
7474 }
7575
7676 static void createTempDirectory (Function doNext) {
77- Directory .systemTemp.createTemp ('dart_file' ).then ((temp) {
78- tempDirectory = temp;
79- doNext ();
80- });
77+ tempDirectory = Directory .systemTemp.createTempSync ('dart_file' );
78+ doNext ();
8179 }
8280
8381 static void createLargeFile (Function doNext) {
@@ -1846,22 +1844,13 @@ class FileTest {
18461844 static testMain () {
18471845 asyncStart ();
18481846
1849- testRead ();
1850- testReadSync ();
1851- testReadStream ();
1852- testLengthSync ();
1853- testPositionSync ();
1854- testOpenDirectoryAsFile ();
1855- testOpenDirectoryAsFileSync ();
1856- testReadAsBytesSync ();
1857- testReadAsBytesSyncEmptyFile ();
1858- testReadAsTextSync ();
1859- testReadAsTextSyncEmptyFile ();
1860- testReadAsLinesSync ();
1861- testLastModifiedSync ();
1862- testLastAccessedSync ();
1863-
18641847 createTempDirectory (() {
1848+ // `testAbsolute` sets the current working directory so run it first
1849+ // (synchronously) so that it doesn't change the working directory while
1850+ // other tests are running.
1851+ //
1852+ // This is a hack. Really, all of the tests should be run consecutively.
1853+ testAbsolute ();
18651854 testLength ();
18661855 testLengthSyncDirectory ();
18671856 testReadWrite ();
@@ -1924,13 +1913,31 @@ class FileTest {
19241913 testSetLastAccessedSync ();
19251914 testSetLastAccessedSyncDirectory ();
19261915 testDoubleAsyncOperation ();
1927- testAbsolute ();
19281916 createLargeFile (() {
19291917 testReadAsBytesLargeFile ();
19301918 testReadAsBytesSyncLargeFile ();
1919+ // This `asyncEnd` pairs with the one called immediately on entry to
1920+ // `testMain`.
1921+ // We are calling this without actually knowing that all asynchronous
1922+ // operations have completed. This hack works because, in practice,
1923+ // the large file tests are the slowest to run.
19311924 asyncEnd ();
19321925 });
19331926 });
1927+ testRead ();
1928+ testReadSync ();
1929+ testReadStream ();
1930+ testLengthSync ();
1931+ testPositionSync ();
1932+ testOpenDirectoryAsFile ();
1933+ testOpenDirectoryAsFileSync ();
1934+ testReadAsBytesSync ();
1935+ testReadAsBytesSyncEmptyFile ();
1936+ testReadAsTextSync ();
1937+ testReadAsTextSyncEmptyFile ();
1938+ testReadAsLinesSync ();
1939+ testLastModifiedSync ();
1940+ testLastAccessedSync ();
19341941 }
19351942}
19361943
0 commit comments