Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
8366b272
Unverified
Commit
8366b272
authored
Jan 28, 2020
by
Mouad Debbar
Committed by
GitHub
Jan 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Serve dart files correctly when running "flutter test" in Chrome (#49325)
parent
da0a7d8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
12 deletions
+55
-12
flutter_web_platform.dart
...ages/flutter_tools/lib/src/test/flutter_web_platform.dart
+55
-12
No files found.
packages/flutter_tools/lib/src/test/flutter_web_platform.dart
View file @
8366b272
...
...
@@ -9,6 +9,9 @@ import 'dart:typed_data';
import
'package:async/async.dart'
;
import
'package:http_multi_server/http_multi_server.dart'
;
import
'package:meta/meta.dart'
;
import
'package:package_config/discovery.dart'
;
import
'package:package_config/packages.dart'
;
import
'package:path/path.dart'
as
p
;
// ignore: package_path_import
import
'package:pool/pool.dart'
;
import
'package:shelf/shelf.dart'
as
shelf
;
...
...
@@ -50,14 +53,6 @@ class FlutterWebPlatform extends PlatformPlugin {
String
shellPath
,
this
.
updateGoldens
,
})
{
// Look up the location of the testing resources.
final
Map
<
String
,
Uri
>
packageMap
=
PackageMap
(
globals
.
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_tools'
,
'.packages'
,
)).
map
;
testUri
=
packageMap
[
'test'
];
final
shelf
.
Cascade
cascade
=
shelf
.
Cascade
()
.
add
(
_webSocketHandler
.
handler
)
.
add
(
packagesDirHandler
())
...
...
@@ -66,11 +61,18 @@ class FlutterWebPlatform extends PlatformPlugin {
globals
.
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_tools'
),
serveFilesOutsidePath:
true
,
))
.
add
(
createStaticHandler
(
_config
.
suiteDefaults
.
precompiledPath
,
serveFilesOutsidePath:
true
))
.
add
(
createStaticHandler
(
_config
.
suiteDefaults
.
precompiledPath
,
serveFilesOutsidePath:
true
,
))
.
add
(
_handleStaticArtifact
)
.
add
(
_goldenFileHandler
)
.
add
(
_wrapperHandler
);
.
add
(
_wrapperHandler
)
.
add
(
createStaticHandler
(
p
.
join
(
p
.
current
,
'test'
),
serveFilesOutsidePath:
true
,
))
.
add
(
_packageFilesHandler
);
_server
.
mount
(
cascade
.
handler
);
_testGoldenComparator
=
TestGoldenComparator
(
...
...
@@ -97,14 +99,30 @@ class FlutterWebPlatform extends PlatformPlugin {
);
}
Uri
testUri
;
final
Future
<
Packages
>
_packagesFuture
=
loadPackagesFile
(
Uri
.
base
.
resolve
(
'.packages'
));
final
PackageMap
_flutterToolsPackageMap
=
PackageMap
(
p
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_tools'
,
'.packages'
,
));
/// Uri of the test package.
Uri
get
testUri
=>
_flutterToolsPackageMap
.
map
[
'test'
];
/// The test runner configuration.
final
Configuration
_config
;
@visibleForTesting
Configuration
get
config
=>
_config
;
/// The underlying server.
final
shelf
.
Server
_server
;
@visibleForTesting
shelf
.
Server
get
server
=>
_server
;
/// The URL for this server.
Uri
get
url
=>
_server
.
url
;
...
...
@@ -193,6 +211,31 @@ class FlutterWebPlatform extends PlatformPlugin {
}
}
FutureOr
<
shelf
.
Response
>
_packageFilesHandler
(
shelf
.
Request
request
)
async
{
if
(
request
.
requestedUri
.
pathSegments
.
first
==
'packages'
)
{
final
Packages
packages
=
await
_packagesFuture
;
final
Uri
fileUri
=
packages
.
resolve
(
Uri
(
scheme:
'package'
,
pathSegments:
request
.
requestedUri
.
pathSegments
.
skip
(
1
),
));
final
String
dirname
=
p
.
dirname
(
fileUri
.
toFilePath
());
final
String
basename
=
p
.
basename
(
fileUri
.
toFilePath
());
final
shelf
.
Handler
handler
=
createStaticHandler
(
dirname
);
final
shelf
.
Request
modifiedRequest
=
shelf
.
Request
(
request
.
method
,
request
.
requestedUri
.
replace
(
path:
basename
),
protocolVersion:
request
.
protocolVersion
,
headers:
request
.
headers
,
handlerPath:
request
.
handlerPath
,
url:
request
.
url
.
replace
(
path:
basename
),
encoding:
request
.
encoding
,
context:
request
.
context
,
);
return
handler
(
modifiedRequest
);
}
return
shelf
.
Response
.
notFound
(
'Not Found'
);
}
final
bool
updateGoldens
;
TestGoldenComparator
_testGoldenComparator
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment