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

Unified Diff: samples/sample_extension/test/sample_extension_test.dart

Issue 2475523002: Reload native extensions when starting from a snapshot. (Closed)
Patch Set: comment Created 4 years, 1 month 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: samples/sample_extension/test/sample_extension_test.dart
diff --git a/samples/sample_extension/test/sample_extension_test.dart b/samples/sample_extension/test/sample_extension_test.dart
index 9c0a42d30468c79d2a4caafba5165a0ad5df1a88..4311ff544f79bb0311a94204b2b994ff1ec3af1f 100644
--- a/samples/sample_extension/test/sample_extension_test.dart
+++ b/samples/sample_extension/test/sample_extension_test.dart
@@ -1,72 +1,11 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// Dart test program for testing native extensions.
-import 'dart:async';
-import 'dart:io';
-import 'dart:isolate';
-
-import "package:expect/expect.dart";
-import "package:path/path.dart";
-
-Future copyFileToDirectory(String file, String directory) {
- String src = file;
- String dst = directory;
- switch (Platform.operatingSystem) {
- case 'linux':
- case 'macos':
- return Process.run('cp', [src, dst]);
- case 'windows':
- return Process.run('cmd.exe', ['/C', 'copy $src $dst']);
- default:
- Expect.fail('Unknown operating system ${Platform.operatingSystem}');
- }
-}
-
-String getNativeLibraryPath(String buildDirectory) {
- switch (Platform.operatingSystem) {
- case 'linux':
- return join(buildDirectory, 'lib.target', 'libsample_extension.so');
- case 'macos':
- return join(buildDirectory, 'libsample_extension.dylib');
- case 'windows':
- return join(buildDirectory, 'sample_extension.dll');
- default:
- Expect.fail('Unknown operating system ${Platform.operatingSystem}');
- }
-}
+import 'sample_extension_test_helper.dart';
void main() {
- String buildDirectory = dirname(Platform.executable);
- Directory tempDirectory =
- Directory.systemTemp.createTempSync('sample_extension_');
- String testDirectory = tempDirectory.path;
- String sourceDirectory = Platform.script.resolve('..').toFilePath();
-
- // Copy sample_extension shared library, sample_extension dart files and
- // sample_extension tests to the temporary test directory.
- copyFileToDirectory(getNativeLibraryPath(buildDirectory), testDirectory)
- .then((_) => Future.forEach(['sample_synchronous_extension.dart',
- 'sample_asynchronous_extension.dart',
- 'test_sample_synchronous_extension.dart',
- 'test_sample_asynchronous_extension.dart'],
- (file) => copyFileToDirectory(join(sourceDirectory, file), testDirectory)
- ))
-
- .then((_) => Future.forEach(['test_sample_synchronous_extension.dart',
- 'test_sample_asynchronous_extension.dart'],
- (test) => Process.run(Platform.executable, [join(testDirectory, test)])
- .then((ProcessResult result) {
- if (result.exitCode != 0) {
- print('Failing test: ${join(sourceDirectory, test)}');
- print('Failing process stdout: ${result.stdout}');
- print('Failing process stderr: ${result.stderr}');
- print('End failing process stderr');
- Expect.fail('Test failed with exit code ${result.exitCode}');
- }
- })
- ))
- .whenComplete(() => tempDirectory.deleteSync(recursive: true));
+ testNativeExtensions(null /* no snapshot */);
}

Powered by Google App Engine
This is Rietveld 408576698