-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Right now a (lint) rule test can stub out a package in the setUp
method like so:
void setUp() {
super.setUp();
var matcherPath = '/packages/matcher';
newFile('$matcherPath/lib/matcher.dart', '''
void expect(dynamic actual, dynamic matcher) {}
const isNotNull = 0;
const isNull = 0;
''');
writeTestPackageConfig(
PackageConfigFileBuilder()
..add(name: 'matcher', rootPath: convertPath(matcherPath)),
);
}
This could be made simpler, without much complexity. But it might be nice to discuss design for a moment.
The basic idea is that certain lint rules might check things like "Is this SimpleIdentifier spelled 'expect'? And is this SimpleIdentifier from the 'matcher' package?". And those checks should work on mock/stub packages (in a test) or on real ones. And test code needs to be able to refer to 'expect' from the 'matcher' package.
So you want to be able to write one or more files in a separate package, such that those files can be imported with a package:
syntax. And those files should be written to file system, and also the package should be added to the test package config.