Add test directive to include other files used by a test in its compiled output directory.

Fixes #27591

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2423593002 .
This commit is contained in:
Ryan Macnak 2016-10-14 16:11:25 -07:00
parent 0ac91fab5c
commit fe04737a77
32 changed files with 139 additions and 53 deletions

View file

@ -2,6 +2,10 @@
// 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.
// Testing file input stream, VM-only, standalone test.
//
// OtherResources=readuntil_test.dat
// OtherResources=readline_test1.dat
// OtherResources=readline_test2.dat
import "dart:convert";
import "dart:io";
@ -9,17 +13,12 @@ import "dart:io";
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
// Helper method to be able to run the test from the runtime
// directory, or the top directory.
String getFilename(String path) {
var testPath = Platform.script.resolve('../../../$path');
return new File.fromUri(testPath).existsSync()
? testPath.toFilePath()
: Platform.script.resolve('../../../runtime/$path').toFilePath();
return Platform.script.resolve(path).toFilePath();
}
void testStringLineSplitter() {
String fileName = getFilename("tests/standalone/io/readuntil_test.dat");
String fileName = getFilename("readuntil_test.dat");
// File contains "Hello Dart\nwassup!\n"
File file = new File(fileName);
int linesRead = 0;
@ -41,7 +40,7 @@ void testStringLineSplitter() {
void testOpenStreamAsync() {
asyncStart();
String fileName = getFilename("tests/standalone/io/readuntil_test.dat");
String fileName = getFilename("readuntil_test.dat");
// File contains "Hello Dart\nwassup!\n"
var expected = "Hello Dart\nwassup!\n".codeUnits;
var byteCount = 0;
@ -234,7 +233,7 @@ void testInputStreamBadOffset() {
void testStringLineSplitterEnding(String name, int length) {
String fileName = getFilename("tests/standalone/io/$name");
String fileName = getFilename(name);
// File contains 10 lines.
File file = new File(fileName);
Expect.equals(length, file.lengthSync());

View file

@ -2,6 +2,8 @@
// 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.
// OtherResources=fixed_length_file
import "dart:async";
import "dart:io";
@ -9,7 +11,7 @@ import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
void testReadInvalidArgs(arg) {
String filename = getFilename("tests/vm/data/fixed_length_file");
String filename = getFilename("fixed_length_file");
var file = (new File(filename)).openSync();
Expect.throws(() => file.readSync(arg),
(e) => e is ArgumentError);
@ -20,7 +22,7 @@ void testReadInvalidArgs(arg) {
}
void testReadIntoInvalidArgs(buffer, start, end) {
String filename = getFilename("tests/vm/data/fixed_length_file");
String filename = getFilename("fixed_length_file");
var file = (new File(filename)).openSync();
Expect.throws(() => file.readIntoSync(buffer, start, end),
(e) => e is ArgumentError);
@ -31,7 +33,7 @@ void testReadIntoInvalidArgs(buffer, start, end) {
}
void testWriteByteInvalidArgs(value) {
String filename = getFilename("tests/vm/data/fixed_length_file");
String filename = getFilename("fixed_length_file");
var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
Expect.throws(() => file.writeByteSync(value),
(e) => e is ArgumentError);
@ -42,7 +44,7 @@ void testWriteByteInvalidArgs(value) {
}
void testWriteFromInvalidArgs(buffer, start, end) {
String filename = getFilename("tests/vm/data/fixed_length_file");
String filename = getFilename("fixed_length_file");
var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
Expect.throws(() => file.writeFromSync(buffer, start, end),
(e) => e is ArgumentError);
@ -53,7 +55,7 @@ void testWriteFromInvalidArgs(buffer, start, end) {
}
void testWriteStringInvalidArgs(string, encoding) {
String filename = getFilename("tests/vm/data/fixed_length_file");
String filename = getFilename("fixed_length_file");
var file = new File("${filename}_out").openSync(mode: FileMode.WRITE);
Expect.throws(() => file.writeStringSync(string, encoding: encoding),
(e) => e is ArgumentError);
@ -99,10 +101,7 @@ void testFileSystemEntity() {
}
String getFilename(String path) {
var testPath = Platform.script.resolve('../../../$path');
return new File.fromUri(testPath).existsSync()
? testPath.toFilePath()
: Platform.script.resolve('../../../runtime/$path').toFilePath();
return Platform.script.resolve(path).toFilePath();
}
main() {

View file

@ -0,0 +1 @@
This file should contain exactly 42 bytes.

View file

@ -2,6 +2,10 @@
// 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.
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "package:convert/convert.dart";
import "package:crypto/crypto.dart";
import "package:expect/expect.dart";

View file

@ -2,6 +2,10 @@
// 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.
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "package:convert/convert.dart";
import "package:crypto/crypto.dart";
import "package:expect/expect.dart";

View file

@ -2,6 +2,10 @@
// 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.
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
// This test verifies that the bad certificate callback works in HttpClient.
import "dart:async";

View file

@ -1,6 +1,10 @@
// Copyright (c) 2012, 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.
//
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
//
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// This test verifies that secure connections that fail due to
// unauthenticated certificates throw exceptions in HttpClient.

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,11 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
// OtherResources=certificates/untrusted_server_chain.pem
// OtherResources=certificates/untrusted_server_key.pem
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "package:expect/expect.dart";
import "package:path/path.dart";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "package:expect/expect.dart";
import "package:path/path.dart";

View file

@ -1,6 +1,8 @@
// Copyright (c) 2012, 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.
//
// OtherResources=readline_test1.dat
// Regression test for missing immutability check in the ListSet
// methods in the API. This allowed overwriting const Lists.
@ -9,19 +11,15 @@ import "package:expect/expect.dart";
import "dart:io";
String getFilename(String path) {
var testPath = Platform.script.resolve('../../../$path');
return new File.fromUri(testPath).existsSync()
? testPath.toFilePath()
: Platform.script.resolve('../../../runtime/$path').toFilePath();
return Platform.script.resolve(path).toFilePath();
}
void main() {
var a = const [0];
var b = const [0];
Expect.identical(a, b);
String filename = getFilename("bin/file_test.cc");
String filename = getFilename("readline_test1.dat");
File file = new File(filename);
file.open().then((input) {
try {

View file

@ -2,6 +2,10 @@
// 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.
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "package:expect/expect.dart";
import "package:path/path.dart";
import "package:async_helper/async_helper.dart";

View file

@ -11,7 +11,8 @@ import 'dart:async';
import 'dart:io';
main() {
String testsDir = Platform.script.resolve('../..').toFilePath();
String testsDir = Directory.current.uri.resolve('tests').toFilePath();
// All of these tests test that resolveSymbolicLinks gives a path
// that points to the same place as the original, and that it removes
// all links, .., and . segments, and that it produces an absolute path.

View file

@ -2,6 +2,10 @@
// 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.
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
// This test verifies that the bad certificate callback works.
import "dart:async";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -2,6 +2,19 @@
// 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.
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
// OtherResources=certificates/client_authority.pem
// OtherResources=certificates/client1.pem
// OtherResources=certificates/client1_key.pem
// OtherResources=certificates/server_chain.p12
// OtherResources=certificates/server_key.p12
// OtherResources=certificates/trusted_certs.p12
// OtherResources=certificates/client_authority.p12
// OtherResources=certificates/client1.p12
// OtherResources=certificates/client1_key.p12
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -15,6 +15,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -1,6 +1,10 @@
// Copyright (c) 2015, 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.
//
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import 'dart:io';
import 'dart:convert';

View file

@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
//
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// This test verifies that client certificates work, if the client and server
// are in separate processes, and that connection renegotiation works, and

View file

@ -6,6 +6,12 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
// OtherResources=certificates/server_chain.p12
// OtherResources=certificates/server_key.p12
// OtherResources=certificates/trusted_certs.p12
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";

View file

@ -1,6 +1,15 @@
// Copyright (c) 2015, 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.
//
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/server_key.p12
// OtherResources=certificates/client1_key_malformed.pem
// OtherResources=certificates/trusted_certs_malformed.pem
// OtherResources=certificates/server_chain_malformed1.pem
// OtherResources=certificates/server_chain_malformed2.pem
// OtherResources=certificates/client_authority_malformed.pem
import "package:expect/expect.dart";
import "dart:io";

View file

@ -6,6 +6,9 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// OtherResources=certificates/trusted_certs.pem
import "dart:async";
import "dart:io";

View file

@ -6,6 +6,8 @@
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
library dart.io;

View file

@ -351,31 +351,3 @@ io/socket_bind_test: Skip
io/http_proxy_advanced_test: Skip
io/http_ipv6_test: Skip
io/socket_ipv6_test: Skip
[ $runtime == dart_app || $runtime == dart_precompiled ]
# Issue 27591 - resource not available relative to generated snapshot
io/file_input_stream_test: Fail
io/file_invalid_arguments_test: Fail
io/http_proxy_advanced_test: Fail
io/http_proxy_test: Fail
io/https_bad_certificate_test: Fail
io/https_server_test: Fail
io/raw_secure_server_closing_test: Fail
io/raw_secure_server_socket_test: Fail
io/raw_secure_socket_pause_test: Fail
io/raw_secure_socket_test: Fail
io/read_into_const_list_test: Fail
io/regress_21160_test: Fail
io/resolve_symbolic_links_test: Fail
io/secure_bad_certificate_test: Fail
io/secure_client_raw_server_test: Fail
io/secure_client_server_test: Fail
io/secure_multiple_client_server_test: Fail
io/secure_server_client_certificate_test: Fail
io/secure_server_closing_test: Fail
io/secure_server_socket_test: Fail
io/secure_session_resume_test: Fail
io/secure_socket_alpn_test: Fail
io/secure_socket_test: Fail
io/security_context_argument_test: Fail
io/socket_upgrade_to_secure_test: Fail

View file

@ -1069,6 +1069,15 @@ class StandardTestSuite extends TestSuite {
path = path.join(new Path(vmOptionsVarient.toString()));
}
tempDir = createCompilationOutputDirectory(path);
List<String> otherResources = info.optionsFromFile['otherResources'];
for (String name in otherResources) {
Path namePath = new Path(name);
String fileName = namePath.filename;
Path fromPath = info.filePath.directoryPath.join(namePath);
new File('$tempDir/$name').parent.createSync(recursive: true);
new File(fromPath.toNativePath()).copySync('$tempDir/$name');
}
}
CommandArtifact compilationArtifact =
@ -1673,6 +1682,7 @@ class StandardTestSuite extends TestSuite {
RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)");
RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)");
RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)");
RegExp otherResourcesRegExp = new RegExp(r"// OtherResources=(.*)");
RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)");
RegExp packagesRegExp = new RegExp(r"// Packages=(.*)");
RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)");
@ -1752,6 +1762,12 @@ class StandardTestSuite extends TestSuite {
otherScripts.addAll(match[1].split(' ').where((e) => e != '').toList());
}
List<String> otherResources = new List<String>();
matches = otherResourcesRegExp.allMatches(contents);
for (var match in matches) {
otherResources.addAll(match[1].split(' ').where((e) => e != '').toList());
}
bool isMultitest = multiTestRegExp.hasMatch(contents);
bool isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents);
Match isolateMatch = isolateStubsRegExp.firstMatch(contents);
@ -1776,6 +1792,7 @@ class StandardTestSuite extends TestSuite {
"hasRuntimeError": false,
"hasStaticWarning": false,
"otherScripts": otherScripts,
"otherResources": otherResources,
"isMultitest": isMultitest,
"isMultiHtmlTest": isMultiHtmlTest,
"subtestNames": subtestNames,