CQ. Use inline expected diagnostics in PubspecDiagnosticTest(s).
Change-Id: Id6f8305c0f5e92ee48cf9c0ac1adc5c2e3a2d490 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511240 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
84088f6a8b
commit
4473de2a5d
@@ -206,6 +206,11 @@ class NodeTextExpectationsCollector {
|
|||||||
methodName: 'assertRuleDiagnosticsInFiles',
|
methodName: 'assertRuleDiagnosticsInFiles',
|
||||||
argument: _ArgumentMapEntryValue(mapArgument: _ArgumentIndex(0)),
|
argument: _ArgumentMapEntryValue(mapArgument: _ArgumentIndex(0)),
|
||||||
),
|
),
|
||||||
|
_AssertMethod(
|
||||||
|
className: 'PubspecDiagnosticTest',
|
||||||
|
methodName: 'assertDiagnostics',
|
||||||
|
argument: _ArgumentIndex(0),
|
||||||
|
),
|
||||||
_AssertMethod(
|
_AssertMethod(
|
||||||
className: 'ResolutionTest',
|
className: 'ResolutionTest',
|
||||||
methodName: 'assertDartObjectText',
|
methodName: 'assertDartObjectText',
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(AssetDirectoryDoesNotExistTest);
|
defineReflectiveTests(AssetDirectoryDoesNotExistTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ main() {
|
|||||||
class AssetDirectoryDoesNotExistTest extends PubspecDiagnosticTest {
|
class AssetDirectoryDoesNotExistTest extends PubspecDiagnosticTest {
|
||||||
test_assetDirectoryDoesExist_noError() {
|
test_assetDirectoryDoesExist_noError() {
|
||||||
newFolder('/sample/assets/logos');
|
newFolder('/sample/assets/logos');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
@@ -26,14 +27,13 @@ flutter:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_assetDirectoryDoesNotExist_error() {
|
test_assetDirectoryDoesNotExist_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/logos/
|
- assets/logos/
|
||||||
''',
|
// ^^^^^^^^^^^^^
|
||||||
[diag.assetDirectoryDoesNotExist],
|
// [diag.assetDirectoryDoesNotExist] The asset directory 'assets/logos/' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,34 +2,34 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(AssetDoesNotExistTest);
|
defineReflectiveTests(AssetDoesNotExistTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class AssetDoesNotExistTest extends PubspecDiagnosticTest {
|
class AssetDoesNotExistTest extends PubspecDiagnosticTest {
|
||||||
test_assetDoesNotExist_path_error() {
|
test_assetDoesNotExist_path_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/my_icon.png
|
- assets/my_icon.png
|
||||||
''',
|
// ^^^^^^^^^^^^^^^^^^
|
||||||
[diag.assetDoesNotExist],
|
// [diag.assetDoesNotExist] The asset file 'assets/my_icon.png' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_assetDoesNotExist_path_inRoot_noError() {
|
test_assetDoesNotExist_path_inRoot_noError() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
@@ -39,7 +39,7 @@ flutter:
|
|||||||
|
|
||||||
test_assetDoesNotExist_path_inSubdir_noError() {
|
test_assetDoesNotExist_path_inSubdir_noError() {
|
||||||
newFile('/sample/assets/images/2.0x/my_icon.png', '');
|
newFile('/sample/assets/images/2.0x/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
@@ -47,23 +47,23 @@ flutter:
|
|||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
@failingTest
|
// TODO(scheglov): Support package assets.
|
||||||
|
@skippedTest
|
||||||
test_assetDoesNotExist_uri_error() {
|
test_assetDoesNotExist_uri_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- packages/icons/my_icon.png
|
- packages/icons/my_icon.png
|
||||||
''',
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
[diag.assetDoesNotExist],
|
// [diag.assetDoesNotExist] The asset file 'packages/icons/my_icon.png' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_assetDoesNotExist_uri_noError() {
|
test_assetDoesNotExist_uri_noError() {
|
||||||
// TODO(brianwilkerson): Create a package named `icons` that contains the
|
// TODO(brianwilkerson): Create a package named `icons` that contains the
|
||||||
// referenced file, and a `.packages` file that references that package.
|
// referenced file, and a `.packages` file that references that package.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
|||||||
@@ -2,44 +2,43 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(AssetFieldNotListTest);
|
defineReflectiveTests(AssetFieldNotListTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class AssetFieldNotListTest extends PubspecDiagnosticTest {
|
class AssetFieldNotListTest extends PubspecDiagnosticTest {
|
||||||
test_assetFieldNotList_error_empty() {
|
test_assetFieldNotList_error_empty() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
''',
|
// ^
|
||||||
[diag.assetFieldNotList],
|
// [diag.assetFieldNotList][column 9][length 0] The value of the 'assets' field is expected to be a list of relative file paths.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_assetFieldNotList_error_string() {
|
test_assetFieldNotList_error_string() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets: assets/my_icon.png
|
assets: assets/my_icon.png
|
||||||
''',
|
// ^^^^^^^^^^^^^^^^^^
|
||||||
[diag.assetFieldNotList],
|
// [diag.assetFieldNotList] The value of the 'assets' field is expected to be a list of relative file paths.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_assetFieldNotList_noError() {
|
test_assetFieldNotList_noError() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(AssetMissingPathTest);
|
defineReflectiveTests(AssetMissingPathTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ main() {
|
|||||||
class AssetMissingPathTest extends PubspecDiagnosticTest {
|
class AssetMissingPathTest extends PubspecDiagnosticTest {
|
||||||
test_assetHasPath() {
|
test_assetHasPath() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
@@ -28,15 +29,13 @@ flutter:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_assetMissingPath() {
|
test_assetMissingPath() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- flavors:
|
- flavors:
|
||||||
|
// [diag.assetMissingPath][column 7][length 27] Asset map entry must contain a 'path' field.
|
||||||
- premium
|
- premium
|
||||||
''',
|
''');
|
||||||
[diag.assetMissingPath],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,34 +2,34 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(AssetNotStringOrMapTest);
|
defineReflectiveTests(AssetNotStringOrMapTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class AssetNotStringOrMapTest extends PubspecDiagnosticTest {
|
class AssetNotStringOrMapTest extends PubspecDiagnosticTest {
|
||||||
test_assetNotString_error_int() {
|
test_assetNotString_error_int() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- 23
|
- 23
|
||||||
''',
|
// ^^
|
||||||
[diag.assetNotStringOrMap],
|
// [diag.assetNotStringOrMap] An asset value is required to be a file path (string) or map.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_assetNotString_error_map() {
|
test_assetNotString_error_map() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
@@ -40,20 +40,19 @@ flutter:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_assetNotString_error_null() {
|
test_assetNotString_error_null() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
-
|
-
|
||||||
''',
|
// ^
|
||||||
[diag.assetNotStringOrMap],
|
// [diag.assetNotStringOrMap][column 5][length 0] An asset value is required to be a file path (string) or map.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_assetNotString_noError() {
|
test_assetNotString_noError() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
|||||||
@@ -2,46 +2,45 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(AssetPathNotStringTest);
|
defineReflectiveTests(AssetPathNotStringTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class AssetPathNotStringTest extends PubspecDiagnosticTest {
|
class AssetPathNotStringTest extends PubspecDiagnosticTest {
|
||||||
test_pathIsList() {
|
test_pathIsList() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- path: [one, two, three]
|
- path: [one, two, three]
|
||||||
''',
|
// ^^^^^^^^^^^^^^^^^
|
||||||
[diag.assetPathNotString],
|
// [diag.assetPathNotString] Asset paths are required to be file paths (strings).
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_pathIsNull() {
|
test_pathIsNull() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- path:
|
- path:
|
||||||
''',
|
// ^
|
||||||
[diag.assetNotString],
|
// [diag.assetNotString][column 11][length 0] Assets are required to be file paths (strings).
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_pathIsString() {
|
test_pathIsString() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
|||||||
@@ -2,38 +2,38 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(DependenciesFieldNotMapTest);
|
defineReflectiveTests(DependenciesFieldNotMapTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class DependenciesFieldNotMapTest extends PubspecDiagnosticTest {
|
class DependenciesFieldNotMapTest extends PubspecDiagnosticTest {
|
||||||
test_dependenciesField_empty() {
|
test_dependenciesField_empty() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_dependenciesFieldNotMap_error_bool() {
|
test_dependenciesFieldNotMap_error_bool() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dependencies: true
|
dependencies: true
|
||||||
''',
|
// ^^^^
|
||||||
[diag.dependenciesFieldNotMap],
|
// [diag.dependenciesFieldNotMap] The value of the 'dependencies' field is expected to be a map.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_dependenciesFieldNotMap_noError() {
|
test_dependenciesFieldNotMap_noError() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
a: any
|
a: any
|
||||||
@@ -41,12 +41,11 @@ dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_devDependenciesFieldNotMap_dev_error_bool() {
|
test_devDependenciesFieldNotMap_dev_error_bool() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dev_dependencies: true
|
dev_dependencies: true
|
||||||
''',
|
// ^^^^
|
||||||
[diag.dependenciesFieldNotMap],
|
// [diag.dependenciesFieldNotMap] The value of the 'dev_dependencies' field is expected to be a map.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,59 +2,52 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(DeprecatedFieldTest);
|
defineReflectiveTests(DeprecatedFieldTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class DeprecatedFieldTest extends PubspecDiagnosticTest {
|
class DeprecatedFieldTest extends PubspecDiagnosticTest {
|
||||||
test_deprecated_author() {
|
test_deprecated_author() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
author: foo
|
author: foo
|
||||||
''',
|
// [diag.deprecatedField][column 1][length 6] The 'author' field is no longer used and can be removed.
|
||||||
[diag.deprecatedField],
|
''');
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_deprecated_authors() {
|
test_deprecated_authors() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
authors:
|
authors:
|
||||||
|
// [diag.deprecatedField][column 1][length 7] The 'authors' field is no longer used and can be removed.
|
||||||
- foo
|
- foo
|
||||||
- bar
|
- bar
|
||||||
''',
|
''');
|
||||||
[diag.deprecatedField],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_deprecated_transformers() {
|
test_deprecated_transformers() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
transformers:
|
transformers:
|
||||||
|
// [diag.deprecatedField][column 1][length 12] The 'transformers' field is no longer used and can be removed.
|
||||||
- foo
|
- foo
|
||||||
''',
|
''');
|
||||||
[diag.deprecatedField],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_deprecated_web() {
|
test_deprecated_web() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
web: foo
|
web: foo
|
||||||
''',
|
// [diag.deprecatedField][column 1][length 3] The 'web' field is no longer used and can be removed.
|
||||||
[diag.deprecatedField],
|
''');
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,26 +2,27 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(FlutterFieldNotMapTest);
|
defineReflectiveTests(FlutterFieldNotMapTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class FlutterFieldNotMapTest extends PubspecDiagnosticTest {
|
class FlutterFieldNotMapTest extends PubspecDiagnosticTest {
|
||||||
test_flutterField_empty_noError() {
|
test_flutterField_empty_noError() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
''');
|
''');
|
||||||
|
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
|
|
||||||
@@ -29,18 +30,17 @@ flutter:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_flutterFieldNotMap_error_bool() {
|
test_flutterFieldNotMap_error_bool() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
flutter: true
|
flutter: true
|
||||||
''',
|
// ^^^^
|
||||||
[diag.flutterFieldNotMap],
|
// [diag.flutterFieldNotMap] The value of the 'flutter' field is expected to be a map.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_flutterFieldNotMap_noError() {
|
test_flutterFieldNotMap_noError() {
|
||||||
newFile('/sample/assets/my_icon.png', '');
|
newFile('/sample/assets/my_icon.png', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(IgnoreDiagnosticTest);
|
defineReflectiveTests(IgnoreDiagnosticTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class IgnoreDiagnosticTest extends PubspecDiagnosticTest {
|
class IgnoreDiagnosticTest extends PubspecDiagnosticTest {
|
||||||
test_comma_separated() {
|
test_comma_separated() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -26,13 +26,13 @@ dependencies:
|
|||||||
path: doesnt/exist
|
path: doesnt/exist
|
||||||
bar:
|
bar:
|
||||||
git: git@github.com:foo/bar.git
|
git: git@github.com:foo/bar.git
|
||||||
''',
|
// ^^^
|
||||||
[diag.invalidDependency],
|
// [diag.invalidDependency] Publishable packages can't have 'git' dependencies.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_file() {
|
test_file() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
# ignore_for_file: invalid_dependency
|
# ignore_for_file: invalid_dependency
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
@@ -45,8 +45,7 @@ dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_line_previous() {
|
test_line_previous() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -55,38 +54,38 @@ dependencies:
|
|||||||
git: git@github.com:foo/foo.git
|
git: git@github.com:foo/foo.git
|
||||||
bar:
|
bar:
|
||||||
git: git@github.com:foo/bar.git
|
git: git@github.com:foo/bar.git
|
||||||
''',
|
// ^^^
|
||||||
[diag.invalidDependency],
|
// [diag.invalidDependency] Publishable packages can't have 'git' dependencies.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_line_same() {
|
test_line_same() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
git: git@github.com:foo/foo.git
|
git: git@github.com:foo/foo.git
|
||||||
|
// ^^^
|
||||||
|
// [diag.invalidDependency] Publishable packages can't have 'git' dependencies.
|
||||||
bar:
|
bar:
|
||||||
git: git@github.com:foo/bar.git # ignore: invalid_dependency
|
git: git@github.com:foo/bar.git # ignore: invalid_dependency
|
||||||
''',
|
''');
|
||||||
[diag.invalidDependency],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_noIgnores() {
|
test_noIgnores() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
git: git@github.com:foo/foo.git
|
git: git@github.com:foo/foo.git
|
||||||
|
// ^^^
|
||||||
|
// [diag.invalidDependency] Publishable packages can't have 'git' dependencies.
|
||||||
bar:
|
bar:
|
||||||
git: git@github.com:foo/bar.git
|
git: git@github.com:foo/bar.git
|
||||||
''',
|
// ^^^
|
||||||
[diag.invalidDependency, diag.invalidDependency],
|
// [diag.invalidDependency] Publishable packages can't have 'git' dependencies.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(InvalidDependencyTest);
|
defineReflectiveTests(InvalidDependencyTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ main() {
|
|||||||
class InvalidDependencyTest extends PubspecDiagnosticTest {
|
class InvalidDependencyTest extends PubspecDiagnosticTest {
|
||||||
test_dependencyGit_malformed_empty() {
|
test_dependencyGit_malformed_empty() {
|
||||||
// TODO(pq): consider validating.
|
// TODO(pq): consider validating.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -27,7 +28,7 @@ dependencies:
|
|||||||
|
|
||||||
test_dependencyGit_malformed_list() {
|
test_dependencyGit_malformed_list() {
|
||||||
// TODO(pq): consider validating.
|
// TODO(pq): consider validating.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -38,7 +39,7 @@ dependencies:
|
|||||||
|
|
||||||
test_dependencyGit_malformed_scalar() {
|
test_dependencyGit_malformed_scalar() {
|
||||||
// TODO(pq): consider validating.
|
// TODO(pq): consider validating.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -47,7 +48,7 @@ dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_dependencyGit_noVersion_valid() {
|
test_dependencyGit_noVersion_valid() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -58,22 +59,21 @@ dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_dependencyGit_version_error() {
|
test_dependencyGit_version_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
git:
|
git:
|
||||||
|
// ^^^
|
||||||
|
// [diag.invalidDependency] Publishable packages can't have 'git' dependencies.
|
||||||
url: git@github.com:foo/foo.git
|
url: git@github.com:foo/foo.git
|
||||||
path: path/to/foo
|
path: path/to/foo
|
||||||
''',
|
''');
|
||||||
[diag.invalidDependency],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_dependencyGit_version_valid() {
|
test_dependencyGit_version_valid() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
publish_to: none
|
publish_to: none
|
||||||
@@ -87,7 +87,7 @@ dependencies:
|
|||||||
|
|
||||||
test_dependencyGitPath() {
|
test_dependencyGitPath() {
|
||||||
// git paths are not validated
|
// git paths are not validated
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -99,7 +99,7 @@ dependencies:
|
|||||||
|
|
||||||
test_dependencyPath_malformed_empty() {
|
test_dependencyPath_malformed_empty() {
|
||||||
// TODO(pq): consider validating.
|
// TODO(pq): consider validating.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -109,7 +109,7 @@ dependencies:
|
|||||||
|
|
||||||
test_dependencyPath_malformed_list() {
|
test_dependencyPath_malformed_list() {
|
||||||
// TODO(pq): consider validating.
|
// TODO(pq): consider validating.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -123,7 +123,7 @@ dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -136,7 +136,7 @@ dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -149,7 +149,7 @@ dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -162,16 +162,15 @@ dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
path: /foo
|
path: /foo
|
||||||
''',
|
// ^^^^
|
||||||
[diag.invalidDependency],
|
// [diag.invalidDependency] Publishable packages can't have 'path' dependencies.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_dependencyPath_version_valid() {
|
test_dependencyPath_version_valid() {
|
||||||
@@ -179,7 +178,7 @@ dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
publish_to: none
|
publish_to: none
|
||||||
@@ -190,14 +189,14 @@ dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_devDependenciesField_empty() {
|
test_devDependenciesField_empty() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_devDependenciesFieldNotMap_dev_noError() {
|
test_devDependenciesFieldNotMap_dev_noError() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
a: any
|
a: any
|
||||||
@@ -206,7 +205,7 @@ dev_dependencies:
|
|||||||
|
|
||||||
test_devDependencyGit_version_no_error() {
|
test_devDependencyGit_version_no_error() {
|
||||||
// Git paths are OK in dev_dependencies
|
// Git paths are OK in dev_dependencies
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(PlatformsFieldTest);
|
defineReflectiveTests(PlatformsFieldTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class PlatformsFieldTest extends PubspecDiagnosticTest {
|
class PlatformsFieldTest extends PubspecDiagnosticTest {
|
||||||
test_empty_platforms_is_allowed() {
|
test_empty_platforms_is_allowed() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms: {} # I don't think you should ever do this!
|
platforms: {} # I don't think you should ever do this!
|
||||||
@@ -24,54 +25,49 @@ platforms: {} # I don't think you should ever do this!
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_invalid_platforms_field() {
|
test_invalid_platforms_field() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
- android
|
- android
|
||||||
|
// [diag.invalidPlatformsField][column 3][length 26] The 'platforms' field must be a map with platforms as keys.
|
||||||
- ios
|
- ios
|
||||||
- web
|
- web
|
||||||
''',
|
''');
|
||||||
[diag.invalidPlatformsField],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_invalid_platforms_field_bool() {
|
test_invalid_platforms_field_bool() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms: true
|
platforms: true
|
||||||
''',
|
// ^^^^
|
||||||
[diag.invalidPlatformsField],
|
// [diag.invalidPlatformsField] The 'platforms' field must be a map with platforms as keys.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_invalid_platforms_field_empty_list() {
|
test_invalid_platforms_field_empty_list() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms: []
|
platforms: []
|
||||||
''',
|
// ^^
|
||||||
[diag.invalidPlatformsField],
|
// [diag.invalidPlatformsField] The 'platforms' field must be a map with platforms as keys.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_invalid_platforms_field_num() {
|
test_invalid_platforms_field_num() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms: 42
|
platforms: 42
|
||||||
''',
|
// ^^
|
||||||
[diag.invalidPlatformsField],
|
// [diag.invalidPlatformsField] The 'platforms' field must be a map with platforms as keys.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_subset_of_supported_platforms_is_allowed() {
|
test_subset_of_supported_platforms_is_allowed() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -82,7 +78,7 @@ platforms:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_supported_platforms_are_allowed() {
|
test_supported_platforms_are_allowed() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -96,26 +92,24 @@ platforms:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform() {
|
test_unknown_platform() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
windåse:
|
windåse:
|
||||||
''',
|
//^^^^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform 'windåse' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_capitalization() {
|
test_unknown_platform_capitalization() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
Windows:
|
Windows:
|
||||||
''',
|
//^^^^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform 'Windows' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,25 +2,30 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(MissingNameTest);
|
defineReflectiveTests(MissingNameTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class MissingNameTest extends PubspecDiagnosticTest {
|
class MissingNameTest extends PubspecDiagnosticTest {
|
||||||
test_missingName_error() {
|
test_missingName_error() {
|
||||||
assertErrors('', [diag.missingName]);
|
assertDiagnostics(
|
||||||
|
'''
|
||||||
|
|
||||||
|
// [diag.missingName][column 1][length 0] The 'name' field is required but missing.''',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
test_missingName_noError() {
|
test_missingName_noError() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,30 +2,30 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(NameNotStringTest);
|
defineReflectiveTests(NameNotStringTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class NameNotStringTest extends PubspecDiagnosticTest {
|
class NameNotStringTest extends PubspecDiagnosticTest {
|
||||||
test_nameNotString_error_int() {
|
test_nameNotString_error_int() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: 42
|
name: 42
|
||||||
''',
|
// ^^
|
||||||
[diag.nameNotString],
|
// [diag.nameNotString] The value of the 'name' field is required to be a string.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_nameNotString_noError() {
|
test_nameNotString_noError() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,41 +2,40 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(PathDoesNotExistTest);
|
defineReflectiveTests(PathDoesNotExistTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class PathDoesNotExistTest extends PubspecDiagnosticTest {
|
class PathDoesNotExistTest extends PubspecDiagnosticTest {
|
||||||
test_dependencyPathDoesNotExist_path_error() {
|
test_dependencyPathDoesNotExist_path_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
path: does/not/exist
|
path: does/not/exist
|
||||||
''',
|
// ^^^^^^^^^^^^^^
|
||||||
[diag.pathDoesNotExist],
|
// [diag.pathDoesNotExist] The path 'does/not/exist' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_devDependencyPathDoesNotExist_path_error() {
|
test_devDependencyPathDoesNotExist_path_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
foo:
|
foo:
|
||||||
path: does/not/exist
|
path: does/not/exist
|
||||||
''',
|
// ^^^^^^^^^^^^^^
|
||||||
[diag.pathDoesNotExist],
|
// [diag.pathDoesNotExist] The path 'does/not/exist' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_devDependencyPathExists() {
|
test_devDependencyPathExists() {
|
||||||
@@ -44,7 +43,7 @@ dev_dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
foo:
|
foo:
|
||||||
@@ -53,35 +52,35 @@ dev_dependencies:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_screenshotPathDoesNotExist_path_error() {
|
test_screenshotPathDoesNotExist_path_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
screenshots:
|
screenshots:
|
||||||
- description: '...'
|
- description: '...'
|
||||||
path: example/screenshots/no.webp
|
path: example/screenshots/no.webp
|
||||||
''',
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
[diag.pathDoesNotExist],
|
// [diag.pathDoesNotExist] The path 'example/screenshots/no.webp' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_screenshotPathDoesNotExist_path_error_multiple() {
|
test_screenshotPathDoesNotExist_path_error_multiple() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
screenshots:
|
screenshots:
|
||||||
- description: '...'
|
- description: '...'
|
||||||
path: example/screenshots/no.webp
|
path: example/screenshots/no.webp
|
||||||
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
// [diag.pathDoesNotExist] The path 'example/screenshots/no.webp' doesn't exist.
|
||||||
- description: '...'
|
- description: '...'
|
||||||
path: example/screenshots/no.webp
|
path: example/screenshots/no.webp
|
||||||
''',
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
[diag.pathDoesNotExist, diag.pathDoesNotExist],
|
// [diag.pathDoesNotExist] The path 'example/screenshots/no.webp' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_screenshotPathExists() {
|
test_screenshotPathExists() {
|
||||||
newFolder('/sample/example');
|
newFolder('/sample/example');
|
||||||
newFile('/sample/example/yes.webp', '');
|
newFile('/sample/example/yes.webp', '');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
screenshots:
|
screenshots:
|
||||||
- description: '...'
|
- description: '...'
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(PathNotPosixTest);
|
defineReflectiveTests(PathNotPosixTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,16 +21,15 @@ class PathNotPosixTest extends PubspecDiagnosticTest {
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertErrors(
|
assertDiagnostics(r'''
|
||||||
r'''
|
|
||||||
name: sample
|
name: sample
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
publish_to: none
|
publish_to: none
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
path: \foo
|
path: \foo
|
||||||
''',
|
// ^^^^
|
||||||
[diag.pathNotPosix],
|
// [diag.pathNotPosix] The path '\foo' isn't a POSIX-style path.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(PathPubspecDoesNotExistTest);
|
defineReflectiveTests(PathPubspecDoesNotExistTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,15 +18,14 @@ main() {
|
|||||||
class PathPubspecDoesNotExistTest extends PubspecDiagnosticTest {
|
class PathPubspecDoesNotExistTest extends PubspecDiagnosticTest {
|
||||||
test_dependencyPath_pubspecDoesNotExist() {
|
test_dependencyPath_pubspecDoesNotExist() {
|
||||||
newFolder('/foo');
|
newFolder('/foo');
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
path: /foo
|
path: /foo
|
||||||
''',
|
// ^^^^
|
||||||
[diag.pathPubspecDoesNotExist],
|
// [diag.pathPubspecDoesNotExist] The directory '/foo' doesn't contain a pubspec.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_dependencyPath_pubspecExists() {
|
test_dependencyPath_pubspecExists() {
|
||||||
@@ -33,7 +33,7 @@ dependencies:
|
|||||||
newPubspecYamlFile('/foo', '''
|
newPubspecYamlFile('/foo', '''
|
||||||
name: foo
|
name: foo
|
||||||
''');
|
''');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
foo:
|
foo:
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(PlatformValueDisallowedTest);
|
defineReflectiveTests(PlatformValueDisallowedTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class PlatformValueDisallowedTest extends PubspecDiagnosticTest {
|
class PlatformValueDisallowedTest extends PubspecDiagnosticTest {
|
||||||
test_subset_of_supported_platforms_is_allowed() {
|
test_subset_of_supported_platforms_is_allowed() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -27,92 +28,85 @@ platforms:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed() {
|
test_value_for_platform_key_disallowed() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: "chrome" # <-- this is not allowed
|
web: "chrome" # <-- this is not allowed
|
||||||
''',
|
// ^^^^^^^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_empty_list() {
|
test_value_for_platform_key_disallowed_empty_list() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: [] # <-- this is not allowed
|
web: [] # <-- this is not allowed
|
||||||
''',
|
// ^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_empty_map() {
|
test_value_for_platform_key_disallowed_empty_map() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: {} # <-- this is not allowed
|
web: {} # <-- this is not allowed
|
||||||
''',
|
// ^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_false() {
|
test_value_for_platform_key_disallowed_false() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: False # <-- this is not allowed
|
web: False # <-- this is not allowed
|
||||||
''',
|
// ^^^^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_int() {
|
test_value_for_platform_key_disallowed_int() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: 42 # <-- this is not allowed
|
web: 42 # <-- this is not allowed
|
||||||
''',
|
// ^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_list_int() {
|
test_value_for_platform_key_disallowed_list_int() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: [1,2,3] # <-- this is not allowed
|
web: [1,2,3] # <-- this is not allowed
|
||||||
''',
|
// ^^^^^^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_list_string() {
|
test_value_for_platform_key_disallowed_list_string() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -120,15 +114,13 @@ platforms:
|
|||||||
ios:
|
ios:
|
||||||
web:
|
web:
|
||||||
- foo
|
- foo
|
||||||
|
// [diag.platformValueDisallowed][column 4][length 42] Keys in the `platforms` field can't have values.
|
||||||
- bar # <-- this is not allowed
|
- bar # <-- this is not allowed
|
||||||
''',
|
''');
|
||||||
[diag.platformValueDisallowed],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_map() {
|
test_value_for_platform_key_disallowed_map() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -136,22 +128,20 @@ platforms:
|
|||||||
ios:
|
ios:
|
||||||
web:
|
web:
|
||||||
foo: bar # <-- this is not allowed
|
foo: bar # <-- this is not allowed
|
||||||
''',
|
// [diag.platformValueDisallowed][column 5][length 36] Keys in the `platforms` field can't have values.
|
||||||
[diag.platformValueDisallowed],
|
''');
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_value_for_platform_key_disallowed_true() {
|
test_value_for_platform_key_disallowed_true() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
ios:
|
ios:
|
||||||
web: True # <-- this is not allowed
|
web: True # <-- this is not allowed
|
||||||
''',
|
// ^^^^
|
||||||
[diag.platformValueDisallowed],
|
// [diag.platformValueDisallowed] Keys in the `platforms` field can't have values.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(UnknownPlatformsTest);
|
defineReflectiveTests(UnknownPlatformsTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class UnknownPlatformsTest extends PubspecDiagnosticTest {
|
class UnknownPlatformsTest extends PubspecDiagnosticTest {
|
||||||
test_subset_of_supported_platforms_is_allowed() {
|
test_subset_of_supported_platforms_is_allowed() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -27,7 +28,7 @@ platforms:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_supported_platforms_are_allowed() {
|
test_supported_platforms_are_allowed() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
@@ -41,74 +42,68 @@ platforms:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_bool() {
|
test_unknown_platform_bool() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
True:
|
True:
|
||||||
''',
|
//^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform 'true' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_browser() {
|
test_unknown_platform_browser() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
browser: # the correct platform is "web"
|
browser: # the correct platform is "web"
|
||||||
''',
|
//^^^^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform 'browser' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_int() {
|
test_unknown_platform_int() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
33:
|
33:
|
||||||
''',
|
//^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform '33' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_list() {
|
test_unknown_platform_list() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
[1, 2]:
|
[1, 2]:
|
||||||
''',
|
//^^^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform '[1, 2]' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_null() {
|
test_unknown_platform_null() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
null:
|
null:
|
||||||
''',
|
//^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform 'null' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unknown_platform_win32() {
|
test_unknown_platform_win32() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: foo
|
name: foo
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
platforms:
|
platforms:
|
||||||
win32: # the correct platform is "windows"
|
win32: # the correct platform is "windows"
|
||||||
''',
|
//^^^^^
|
||||||
[diag.unknownPlatform],
|
// [diag.unknownPlatform] The platform 'win32' is not a recognized platform.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,47 +2,46 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(UnnecessaryDevDependencyTest);
|
defineReflectiveTests(UnnecessaryDevDependencyTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class UnnecessaryDevDependencyTest extends PubspecDiagnosticTest {
|
class UnnecessaryDevDependencyTest extends PubspecDiagnosticTest {
|
||||||
test_unnecessaryDevDependency_error() {
|
test_unnecessaryDevDependency_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
a: any
|
a: any
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
a: any
|
a: any
|
||||||
''',
|
//^
|
||||||
[diag.unnecessaryDevDependency],
|
// [diag.unnecessaryDevDependency] The dev dependency on a is unnecessary because there is also a normal dependency on that package.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unnecessaryDevDependency_error_null() {
|
test_unnecessaryDevDependency_error_null() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
null: any
|
null: any
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
null: any
|
null: any
|
||||||
''',
|
//^^^^
|
||||||
[diag.unnecessaryDevDependency],
|
// [diag.unnecessaryDevDependency] The dev dependency on null is unnecessary because there is also a normal dependency on that package.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_unnecessaryDevDependency_noError() {
|
test_unnecessaryDevDependency_noError() {
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
dependencies:
|
dependencies:
|
||||||
a: any
|
a: any
|
||||||
|
|||||||
@@ -2,33 +2,33 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
|
||||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||||
|
|
||||||
|
import '../../dart/resolution/node_text_expectations.dart';
|
||||||
import '../pubspec_test_support.dart';
|
import '../pubspec_test_support.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
defineReflectiveSuite(() {
|
defineReflectiveSuite(() {
|
||||||
defineReflectiveTests(WorkspaceFieldTest);
|
defineReflectiveTests(WorkspaceFieldTest);
|
||||||
|
defineReflectiveTests(UpdateNodeTextExpectations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@reflectiveTest
|
@reflectiveTest
|
||||||
class WorkspaceFieldTest extends PubspecDiagnosticTest {
|
class WorkspaceFieldTest extends PubspecDiagnosticTest {
|
||||||
test_workspaceGlob_baseMissing_error() {
|
test_workspaceGlob_baseMissing_error() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- packages/*
|
- packages/*
|
||||||
''',
|
// ^^^^^^^^^^
|
||||||
[diag.pathDoesNotExist],
|
// [diag.pathDoesNotExist] The path 'packages' doesn't exist.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_workspaceGlob_braces_baseExists_noError() {
|
test_workspaceGlob_braces_baseExists_noError() {
|
||||||
newFolder('/sample/packages');
|
newFolder('/sample/packages');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- packages/{a,b}
|
- packages/{a,b}
|
||||||
@@ -37,7 +37,7 @@ workspace:
|
|||||||
|
|
||||||
test_workspaceGlob_nestedBase_baseExists_noError() {
|
test_workspaceGlob_nestedBase_baseExists_noError() {
|
||||||
newFolder('/sample/apps/nested');
|
newFolder('/sample/apps/nested');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- apps/nested/*
|
- apps/nested/*
|
||||||
@@ -46,7 +46,7 @@ workspace:
|
|||||||
|
|
||||||
test_workspaceGlob_noBase_noError() {
|
test_workspaceGlob_noBase_noError() {
|
||||||
// Pattern starts with a glob character — no base directory to check.
|
// Pattern starts with a glob character — no base directory to check.
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- '*'
|
- '*'
|
||||||
@@ -55,7 +55,7 @@ workspace:
|
|||||||
|
|
||||||
test_workspaceGlob_questionMark_baseExists_noError() {
|
test_workspaceGlob_questionMark_baseExists_noError() {
|
||||||
newFolder('/sample/packages');
|
newFolder('/sample/packages');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- packages/pkg?
|
- packages/pkg?
|
||||||
@@ -64,7 +64,7 @@ workspace:
|
|||||||
|
|
||||||
test_workspaceGlob_star_baseExists_noError() {
|
test_workspaceGlob_star_baseExists_noError() {
|
||||||
newFolder('/sample/packages');
|
newFolder('/sample/packages');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- packages/*
|
- packages/*
|
||||||
@@ -72,53 +72,49 @@ workspace:
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_workspaceIsList() {
|
test_workspaceIsList() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
workspace: package1
|
workspace: package1
|
||||||
''',
|
// ^^^^^^^^
|
||||||
[diag.workspaceFieldNotList],
|
// [diag.workspaceFieldNotList] The value of the 'workspace' field is required to be a list of relative file paths.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_workspaceValueIsNotString() {
|
test_workspaceValueIsNotString() {
|
||||||
newFolder('/sample/package1');
|
newFolder('/sample/package1');
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- 23
|
- 23
|
||||||
''',
|
// ^^
|
||||||
[diag.workspaceValueNotString],
|
// [diag.workspaceValueNotString] Workspace entries are required to be directory paths (strings).
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_workspaceValueIsNotSubDirectory() {
|
test_workspaceValueIsNotSubDirectory() {
|
||||||
newFolder('/sample/package1');
|
newFolder('/sample/package1');
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- /sample2
|
- /sample2
|
||||||
''',
|
// ^^^^^^^^
|
||||||
[diag.workspaceValueNotSubdirectory],
|
// [diag.workspaceValueNotSubdirectory] Workspace values must be a relative path of a subdirectory of '/sample'.
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_workspaceValueIsNull() {
|
test_workspaceValueIsNull() {
|
||||||
assertErrors(
|
assertDiagnostics('''
|
||||||
'''
|
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
-
|
-
|
||||||
''',
|
// ^
|
||||||
[diag.workspaceValueNotString],
|
// [diag.workspaceValueNotString][column 5][length 0] Workspace entries are required to be directory paths (strings).
|
||||||
);
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
test_workspaceValueIsString() {
|
test_workspaceValueIsString() {
|
||||||
newFolder('/sample/package1');
|
newFolder('/sample/package1');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- package1
|
- package1
|
||||||
@@ -127,7 +123,7 @@ workspace:
|
|||||||
|
|
||||||
test_workspaceValueIsSubDirectory() {
|
test_workspaceValueIsSubDirectory() {
|
||||||
newFolder('/sample/package1');
|
newFolder('/sample/package1');
|
||||||
assertNoErrors('''
|
assertDiagnostics('''
|
||||||
name: sample
|
name: sample
|
||||||
workspace:
|
workspace:
|
||||||
- package1
|
- package1
|
||||||
|
|||||||
@@ -2,36 +2,43 @@
|
|||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:analyzer/error/error.dart';
|
import 'package:analyzer/diagnostic/diagnostic.dart';
|
||||||
import 'package:analyzer/source/file_source.dart';
|
import 'package:analyzer/source/file_source.dart';
|
||||||
import 'package:analyzer/src/pubspec/pubspec_validator.dart';
|
import 'package:analyzer/src/pubspec/pubspec_validator.dart';
|
||||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||||
|
import 'package:analyzer_testing/src/expected_diagnostics.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
import '../../generated/test_support.dart';
|
import '../../util/diff.dart';
|
||||||
|
import '../dart/resolution/node_text_expectations.dart';
|
||||||
|
|
||||||
class PubspecDiagnosticTest with ResourceProviderMixin {
|
class PubspecDiagnosticTest with ResourceProviderMixin {
|
||||||
/// Assert that when the validator is used on the given [content] the
|
/// Assert that pubspec validator diagnostics match the inline diagnostic
|
||||||
/// [expectedCodes] are produced.
|
/// markers in [content].
|
||||||
void assertErrors(String content, List<DiagnosticCode> expectedCodes) {
|
void assertDiagnostics(String content) {
|
||||||
|
var cleanContent = removeDiagnosticExpectations(content);
|
||||||
|
var diagnostics = _validate(cleanContent);
|
||||||
|
var actual = updateExpectedDiagnostics(
|
||||||
|
content: cleanContent,
|
||||||
|
actualDiagnostics: diagnostics,
|
||||||
|
);
|
||||||
|
if (actual != content) {
|
||||||
|
NodeTextExpectationsCollector.add(actual);
|
||||||
|
printPrettyDiff(content, actual);
|
||||||
|
fail('See the difference above.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Diagnostic> _validate(String content) {
|
||||||
var pubspecFile = newFile('/sample/pubspec.yaml', content);
|
var pubspecFile = newFile('/sample/pubspec.yaml', content);
|
||||||
var source = FileSource(pubspecFile);
|
var source = FileSource(pubspecFile);
|
||||||
YamlNode node = loadYamlNode(content);
|
YamlNode node = loadYamlNode(content);
|
||||||
GatheringDiagnosticListener listener = GatheringDiagnosticListener();
|
return validatePubspec(
|
||||||
listener.addAll(
|
contents: node,
|
||||||
validatePubspec(
|
source: source,
|
||||||
contents: node,
|
provider: resourceProvider,
|
||||||
source: source,
|
// TODO(sigurdm): Can/should we pass analysisOptions here?
|
||||||
provider: resourceProvider,
|
|
||||||
// TODO(sigurdm): Can/should we pass analysisOptions here?
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
listener.assertErrorsWithCodes(expectedCodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Assert that when the validator is used on the given [content] no errors
|
|
||||||
/// are produced.
|
|
||||||
void assertNoErrors(String content) {
|
|
||||||
assertErrors(content, []);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user