Skip to content

Move some e2e tests which use flags or options to package_test.dart #2348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions lib/src/package_meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class _FilePackageMeta extends PubPackageMeta {
if (!_setHostedAt) {
_setHostedAt = true;
// Search for 'hosted/host.domain' as the immediate parent directories,
// and verify that a directory _temp exists alongside hosted. Those
// and verify that a directory "_temp" exists alongside "hosted". Those
// seem to be the only guaranteed things to exist if we're from a pub
// cache.
//
Expand All @@ -317,14 +317,16 @@ class _FilePackageMeta extends PubPackageMeta {
// a pub library to do this.
// People could have a pub cache at root with Windows drive mappings.
if (pathContext.split(pathContext.canonicalize(dir.path)).length >= 3) {
var pubCacheRoot = dir.parent.parent.parent.path;
var hosted = pathContext.canonicalize(dir.parent.parent.path);
var hostname = pathContext.canonicalize(dir.parent.path);
if (pathContext.basename(hosted) == 'hosted' &&
resourceProvider
.getFolder(pathContext.join(pubCacheRoot, '_temp'))
.exists) {
_hostedAt = pathContext.basename(hostname);
var pubCacheRoot = dir.parent.parent.parent?.path;
if (pubCacheRoot != null) {
var hosted = pathContext.canonicalize(dir.parent.parent.path);
var hostname = pathContext.canonicalize(dir.parent.path);
if (pathContext.basename(hosted) == 'hosted' &&
resourceProvider
.getFolder(pathContext.join(pubCacheRoot, '_temp'))
.exists) {
_hostedAt = pathContext.basename(hostname);
}
}
}
}
Expand Down
85 changes: 2 additions & 83 deletions test/end2end/dartdoc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ Folder _getFolder(String p) => _resourceProvider
final _testPackageDir = _getFolder('testing/test_package');

final Folder _testPackageBadDir = _getFolder('testing/test_package_bad');
final Folder _testPackageMinimumDir =
_getFolder('testing/test_package_minimum');
final Folder _testSkyEnginePackage = _getFolder('testing/sky_engine');
final Folder _testPackageIncludeExclude =
_getFolder('testing/test_package_include_exclude');
final Folder _testPackageImportExportError =
_getFolder('testing/test_package_import_export_error');
final Folder _testPackageOptions = _getFolder('testing/test_package_options');
final Folder _testPackageOptionsImporter =
_getFolder('testing/test_package_options_importer');
final _testPackageCustomTemplates =
_getFolder('testing/test_package_custom_templates');

Expand Down Expand Up @@ -162,43 +158,6 @@ void main() {
contains('Tool "drill" returned non-zero exit code'));
});

group('Option handling with cross-linking', () {
DartdocResults results;
Package testPackageOptions;
Folder tempDir;

setUpAll(() async {
tempDir = resourceProvider.createSystemTemp('dartdoc.test.');
results = await (await buildDartdoc(
['--link-to-remote'], _testPackageOptionsImporter, tempDir))
.generateDocsBase();
testPackageOptions = results.packageGraph.packages
.firstWhere((Package p) => p.name == 'test_package_options');
});

test('linkToUrl', () async {
var main = testPackageOptions.allLibraries
.firstWhere((Library l) => l.name == 'main');
var UseAnExampleHere = main.allClasses
.firstWhere((Class c) => c.name == 'UseAnExampleHere');
expect(testPackageOptions.documentedWhere,
equals(DocumentLocation.remote));
expect(
UseAnExampleHere.href,
equals(
'https://nonexistingsuperpackage.topdomain/test_package_options/0.0.1/main/UseAnExampleHere-class.html'));
});

test('includeExternal works via remote', () async {
var unusualLibrary = testPackageOptions.allLibraries
.firstWhere((Library l) => l.name == 'unusualLibrary');
expect(
unusualLibrary.allClasses
.firstWhere((Class c) => c.name == 'Something'),
isNotNull);
});
});

test('with broken reexport chain', () async {
var dartdoc =
await buildDartdoc([], _testPackageImportExportError, tempDir);
Expand Down Expand Up @@ -246,13 +205,6 @@ void main() {
});
});

test('package without version produces valid semver in docs', () async {
var dartdoc = await buildDartdoc([], _testPackageMinimumDir, tempDir);
var results = await dartdoc.generateDocs();
var p = results.packageGraph;
expect(p.defaultPackage.version, equals('0.0.0-unknown'));
});

test('basic interlinking test', () async {
var dartdoc = await buildDartdoc([], _testPackageDir, tempDir);
var results = await dartdoc.generateDocs();
Expand Down Expand Up @@ -327,41 +279,9 @@ void main() {
expect(e is DartdocFailure, isTrue);
}
},
skip: 'Blocked on getting analysis errors with correct interpretation'
skip: 'Blocked on getting analysis errors with correct interpretation '
'from analysis_options');

test('generate docs including a single library', () async {
var dartdoc =
await buildDartdoc(['--include', 'fake'], _testPackageDir, tempDir);

var results = await dartdoc.generateDocs();
expect(results.packageGraph, isNotNull);

var p = results.packageGraph;
expect(p.defaultPackage.name, 'test_package');
expect(p.defaultPackage.hasDocumentationFile, isTrue);
expect(p.localPublicLibraries, hasLength(1));
expect(p.localPublicLibraries.map((lib) => lib.name), contains('fake'));
});

test('generate docs excluding a single library', () async {
var dartdoc =
await buildDartdoc(['--exclude', 'fake'], _testPackageDir, tempDir);

var results = await dartdoc.generateDocs();
expect(results.packageGraph, isNotNull);

var p = results.packageGraph;
expect(p.defaultPackage.name, 'test_package');
expect(p.defaultPackage.hasDocumentationFile, isTrue);
// Plus 1 here because we're excluding only two libraries (the specified
// one and the <nodoc> 'excluded' library) instead of three.
expect(
p.localPublicLibraries, hasLength(kTestPackagePublicLibraries + 1));
expect(p.localPublicLibraries.map((lib) => lib.name).contains('fake'),
isFalse);
});

test('generate docs for package with embedder yaml', () async {
var dartdoc = await buildDartdoc([], _testSkyEnginePackage, tempDir);

Expand Down Expand Up @@ -443,8 +363,7 @@ void main() {
});

test('rel canonical prefix does not include base href', () async {
// ignore: omit_local_variable_types
final String prefix = 'foo.bar/baz';
final prefix = 'foo.bar/baz';
var dartdoc = await buildDartdoc(
['--rel-canonical-prefix', prefix], _testPackageDir, tempDir);
await dartdoc.generateDocsBase();
Expand Down
Loading