| Index: tests/standalone/io/test_extension_test.dart
|
| diff --git a/tests/standalone/io/test_extension_test.dart b/tests/standalone/io/test_extension_test.dart
|
| index 0f032339949b66929e01393eb0a33c67a3b1985f..40d768e2ba6cbda59ee3ebdf81857f52757ade67 100644
|
| --- a/tests/standalone/io/test_extension_test.dart
|
| +++ b/tests/standalone/io/test_extension_test.dart
|
| @@ -12,6 +12,7 @@ import 'dart:isolate';
|
|
|
| Future copyFileToDirectory(String file, String directory) {
|
| switch (Platform.operatingSystem) {
|
| + case 'android':
|
| case 'linux':
|
| case 'macos':
|
| return Process.run('cp', [file, directory]);
|
| @@ -22,30 +23,67 @@ Future copyFileToDirectory(String file, String directory) {
|
| }
|
| }
|
|
|
| -String getExtensionPath(String buildDirectory) {
|
| +// Returns a list containing the source file name in the first element and the
|
| +// target file name in the second element.
|
| +List<String> getExtensionNames(String arch) {
|
| switch (Platform.operatingSystem) {
|
| + case 'android':
|
| case 'linux':
|
| - return join(buildDirectory, 'lib.target', 'libtest_extension.so');
|
| + return ['libtest_extension.so', 'libtest_extension$arch.so'];
|
| case 'macos':
|
| - return join(buildDirectory, 'libtest_extension.dylib');
|
| + return ['libtest_extension.dylib', 'libtest_extension$arch.dylib'];
|
| case 'windows':
|
| - return join(buildDirectory, 'test_extension.dll');
|
| + return ['test_extension.dll','test_extension$arch.dll'];
|
| default:
|
| Expect.fail('Unknown operating system ${Platform.operatingSystem}');
|
| }
|
| }
|
|
|
| -void main() {
|
| +String getExtensionPath(String buildDirectory, String filename) {
|
| + switch (Platform.operatingSystem) {
|
| + case 'android':
|
| + case 'linux':
|
| + return join(buildDirectory, 'lib.target', filename);
|
| + case 'macos':
|
| + case 'windows':
|
| + return join(buildDirectory, filename);
|
| + default:
|
| + Expect.fail('Unknown operating system ${Platform.operatingSystem}');
|
| + }
|
| +}
|
| +
|
| +String getArchFromBuildDir(String buildDirectory) {
|
| + if (buildDirectory.endsWith('SIMARM')) return '';
|
| + if (buildDirectory.endsWith('SIMARM64')) return '';
|
| + if (buildDirectory.endsWith('SIMDBC')) return '';
|
| + if (buildDirectory.endsWith('SIMMIPS')) return '';
|
| + if (buildDirectory.endsWith('ARM')) return '-arm';
|
| + if (buildDirectory.endsWith('ARM64')) return '-arm64';
|
| + if (buildDirectory.endsWith('IA32')) return '-ia32';
|
| + if (buildDirectory.endsWith('MIPS')) return '-mips';
|
| + if (buildDirectory.endsWith('X64')) return '-x64';
|
| + return 'unknown';
|
| +}
|
| +
|
| +Future testExtension(bool withArchSuffix) {
|
| String scriptDirectory = dirname(Platform.script.toFilePath());
|
| String buildDirectory = dirname(Platform.executable);
|
| Directory tempDirectory =
|
| Directory.systemTemp.createTempSync('dart_test_extension');
|
| String testDirectory = tempDirectory.path;
|
|
|
| + List<String> fileNames;
|
| + if (withArchSuffix) {
|
| + String arch = getArchFromBuildDir(buildDirectory);
|
| + fileNames = getExtensionNames(arch);
|
| + } else {
|
| + fileNames = getExtensionNames('');
|
| + }
|
| +
|
| // Copy test_extension shared library, test_extension.dart and
|
| // test_extension_tester.dart to the temporary test directory.
|
| - copyFileToDirectory(getExtensionPath(buildDirectory),
|
| - testDirectory).then((_) {
|
| + return copyFileToDirectory(getExtensionPath(buildDirectory, fileNames[0]),
|
| + join(testDirectory, fileNames[1])).then((_) {
|
| var extensionDartFile = join(scriptDirectory, 'test_extension.dart');
|
| return copyFileToDirectory(extensionDartFile, testDirectory);
|
| }).then((_) {
|
| @@ -69,3 +107,16 @@ void main() {
|
| tempDirectory.deleteSync(recursive: true);
|
| });
|
| }
|
| +
|
| +Future testWithArchSuffix() {
|
| + return testExtension(true);
|
| +}
|
| +
|
| +Future testWithoutArchSuffix() {
|
| + return testExtension(false);
|
| +}
|
| +
|
| +main() async {
|
| + await testWithArchSuffix();
|
| + await testWithoutArchSuffix();
|
| +}
|
|
|