-
Notifications
You must be signed in to change notification settings - Fork 82
Refactor TestContext
constructor for clarity
#1844
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
Conversation
TestContext
constructors for clarity
TestContext
constructors for clarityTestContext
constructor for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Elliott! Generally LGTM with some comments where I am not sure it will work on windows, but the tests would catch them I believe.
this.pathToServe = 'example', | ||
TestContext.withSoundNullSafety({ | ||
String packageName = '_testSound', | ||
String webAssetsPath = 'example/hello_world', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only used in a uri? there are more places like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is only a web uri. I've added a helper webCompatiblePath
for other places, though not here since this is a default param and therefore needs to be const.
dwds/test/fixtures/context.dart
Outdated
/// The URI for the package_config.json is located in: | ||
/// <project directory>/.dart_tool/package_config | ||
Uri get _packageConfigFile => | ||
p.toUri(p.join(workingDirectory, '.dart_tool/package_config.json')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use p.join(workingDirectory, '.dart_tool', 'package_config.json')
so the separators are consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Work towards #1818:
And work towards #1845:
Note: Core of the change is in
context.dart
andutilities.dart
, all other changes are to test files to use the newTestContext
constructors.Refactors the
TestContext
constructor so that there are 2 named constructors:TestContext.withSoundNullSafety()
TestContext.withWeakNullSafety()
Also changes the parameters to the
TestContext
constructors from:String directory
eg"../fixtures/_testPackageSound"
String pathToServe
eg"web"
String entry
eg"../fixtures/_testPackageSound/web"
String path
eg"index.html"
to:
String packageName
eg"_testPackageSound"
String webAssetsPath
eg"web/hello_world"
String dartEntryFileName
eg"main.dart"
String htmlEntryFileName
eg"index.html"
This way all the parameters are self-consistent (no way to pass
"../fixtures/_testPackageSound"
and"../fixtures/_testPackage/web"
for example).Moves the fields being initialized in the constructor into
getters
.Finally, makes the
absolutePath
function inutilities.dart
more flexible by allowing clients to specifypathFromWebdev
orpathFromFixtures
along withpathFromDwds
.