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
1e062800
Unverified
Commit
1e062800
authored
Nov 20, 2020
by
Jonah Williams
Committed by
GitHub
Nov 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[devicelab] dont use set modified for hot reload bench (#70965)
parent
c07661cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
88 deletions
+96
-88
hot_mode_tests.dart
dev/devicelab/lib/tasks/hot_mode_tests.dart
+96
-88
No files found.
dev/devicelab/lib/tasks/hot_mode_tests.dart
View file @
1e062800
...
@@ -19,6 +19,11 @@ const String kSourceLine = 'fontSize: (orientation == Orientation.portrait) ? 32
...
@@ -19,6 +19,11 @@ const String kSourceLine = 'fontSize: (orientation == Orientation.portrait) ? 32
const
String
kReplacementLine
=
'fontSize: (orientation == Orientation.portrait) ? 34.0 : 24.0'
;
const
String
kReplacementLine
=
'fontSize: (orientation == Orientation.portrait) ? 34.0 : 24.0'
;
TaskFunction
createHotModeTest
(
{
String
deviceIdOverride
,
Map
<
String
,
String
>
environment
})
{
TaskFunction
createHotModeTest
(
{
String
deviceIdOverride
,
Map
<
String
,
String
>
environment
})
{
// This file is modified during the test and needs to be restored at the end.
final
File
flutterFrameworkSource
=
file
(
path
.
join
(
flutterDirectory
.
path
,
'packages/flutter/lib/src/widgets/framework.dart'
,
));
final
String
oldContents
=
flutterFrameworkSource
.
readAsStringSync
();
return
()
async
{
return
()
async
{
if
(
deviceIdOverride
==
null
)
{
if
(
deviceIdOverride
==
null
)
{
final
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
...
@@ -42,101 +47,104 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
...
@@ -42,101 +47,104 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
mkdirs
(
_editedFlutterGalleryDir
);
mkdirs
(
_editedFlutterGalleryDir
);
recursiveCopy
(
flutterGalleryDir
,
_editedFlutterGalleryDir
);
recursiveCopy
(
flutterGalleryDir
,
_editedFlutterGalleryDir
);
await
inDirectory
<
void
>(
_editedFlutterGalleryDir
,
()
async
{
try
{
smallReloadData
=
await
captureReloadData
(
options
,
environment
,
benchmarkFile
,
(
String
line
,
Process
process
)
{
await
inDirectory
<
void
>(
_editedFlutterGalleryDir
,
()
async
{
if
(!
line
.
contains
(
'Reloaded '
))
{
smallReloadData
=
await
captureReloadData
(
options
,
environment
,
benchmarkFile
,
(
String
line
,
Process
process
)
{
return
;
if
(!
line
.
contains
(
'Reloaded '
))
{
}
return
;
if
(
hotReloadCount
==
0
)
{
}
// Update a file for 2 library invalidation.
if
(
hotReloadCount
==
0
)
{
final
File
appDartSource
=
file
(
path
.
join
(
// Update a file for 2 library invalidation.
_editedFlutterGalleryDir
.
path
,
'lib/gallery/app.dart'
,
final
File
appDartSource
=
file
(
path
.
join
(
));
_editedFlutterGalleryDir
.
path
,
'lib/gallery/app.dart'
,
appDartSource
.
writeAsStringSync
(
appDartSource
.
readAsStringSync
().
replaceFirst
(
"'Flutter Gallery'"
,
"'Updated Flutter Gallery'"
,
));
));
process
.
stdin
.
writeln
(
'r'
);
appDartSource
.
writeAsStringSync
(
hotReloadCount
+=
1
;
appDartSource
.
readAsStringSync
().
replaceFirst
(
}
else
{
"'Flutter Gallery'"
,
"'Updated Flutter Gallery'"
,
process
.
stdin
.
writeln
(
'q'
);
));
}
process
.
stdin
.
writeln
(
'r'
);
});
hotReloadCount
+=
1
;
}
else
{
mediumReloadData
=
await
captureReloadData
(
options
,
environment
,
benchmarkFile
,
(
String
line
,
Process
process
)
{
if
(!
line
.
contains
(
'Reloaded '
))
{
return
;
}
if
(
hotReloadCount
==
1
)
{
// Update a file for ~50 library invalidation.
final
File
appDartSource
=
file
(
path
.
join
(
_editedFlutterGalleryDir
.
path
,
'lib/demo/calculator/home.dart'
,
));
appDartSource
.
writeAsStringSync
(
appDartSource
.
readAsStringSync
().
replaceFirst
(
kSourceLine
,
kReplacementLine
)
);
process
.
stdin
.
writeln
(
'r'
);
hotReloadCount
+=
1
;
}
else
{
process
.
stdin
.
writeln
(
'q'
);
}
});
largeReloadData
=
await
captureReloadData
(
options
,
environment
,
benchmarkFile
,
(
String
line
,
Process
process
)
{
if
(!
line
.
contains
(
'Reloaded '
))
{
return
;
}
if
(
hotReloadCount
==
2
)
{
// Trigger a framework invalidation (370 libraries) without modifying the source
final
File
flutterFrameworkSource
=
file
(
path
.
join
(
flutterDirectory
.
path
,
'packages/flutter/lib/src/widgets/framework.dart'
,
));
flutterFrameworkSource
.
setLastModifiedSync
(
DateTime
.
now
());
process
.
stdin
.
writeln
(
'r'
);
hotReloadCount
+=
1
;
}
else
{
process
.
stdin
.
writeln
(
'q'
);
}
});
// Start `flutter run` again to make sure it loads from the previous
// state. Frontend loads up from previously generated kernel files.
{
final
Process
process
=
await
startProcess
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
flutterCommandArgs
(
'run'
,
options
),
environment:
environment
,
);
final
Completer
<
void
>
stdoutDone
=
Completer
<
void
>();
final
Completer
<
void
>
stderrDone
=
Completer
<
void
>();
process
.
stdout
.
transform
<
String
>(
utf8
.
decoder
)
.
transform
<
String
>(
const
LineSplitter
())
.
listen
((
String
line
)
{
if
(
line
.
contains
(
'Reloaded '
))
{
process
.
stdin
.
writeln
(
'q'
);
process
.
stdin
.
writeln
(
'q'
);
}
}
print
(
'stdout:
$line
'
);
},
onDone:
()
{
stdoutDone
.
complete
();
});
});
process
.
stderr
.
transform
<
String
>(
utf8
.
decoder
)
mediumReloadData
=
await
captureReloadData
(
options
,
environment
,
benchmarkFile
,
(
String
line
,
Process
process
)
{
.
transform
<
String
>(
const
LineSplitter
())
if
(!
line
.
contains
(
'Reloaded '
))
{
.
listen
((
String
line
)
{
return
;
print
(
'stderr:
$line
'
);
}
},
onDone:
()
{
if
(
hotReloadCount
==
1
)
{
stderrDone
.
complete
();
// Update a file for ~50 library invalidation.
final
File
appDartSource
=
file
(
path
.
join
(
_editedFlutterGalleryDir
.
path
,
'lib/demo/calculator/home.dart'
,
));
appDartSource
.
writeAsStringSync
(
appDartSource
.
readAsStringSync
().
replaceFirst
(
kSourceLine
,
kReplacementLine
)
);
process
.
stdin
.
writeln
(
'r'
);
hotReloadCount
+=
1
;
}
else
{
process
.
stdin
.
writeln
(
'q'
);
}
});
});
await
Future
.
wait
<
void
>(
largeReloadData
=
await
captureReloadData
(
options
,
environment
,
benchmarkFile
,
(
String
line
,
Process
process
)
{
<
Future
<
void
>>[
stdoutDone
.
future
,
stderrDone
.
future
]);
if
(!
line
.
contains
(
'Reloaded '
))
{
await
process
.
exitCode
;
return
;
}
if
(
hotReloadCount
==
2
)
{
// Trigger a framework invalidation (370 libraries) without modifying the source
flutterFrameworkSource
.
writeAsStringSync
(
flutterFrameworkSource
.
readAsStringSync
()
+
'
\n
'
);
process
.
stdin
.
writeln
(
'r'
);
hotReloadCount
+=
1
;
}
else
{
process
.
stdin
.
writeln
(
'q'
);
}
});
freshRestartReloadsData
=
// Start `flutter run` again to make sure it loads from the previous
json
.
decode
(
benchmarkFile
.
readAsStringSync
())
as
Map
<
String
,
dynamic
>;
// state. Frontend loads up from previously generated kernel files.
}
{
});
final
Process
process
=
await
startProcess
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
flutterCommandArgs
(
'run'
,
options
),
environment:
environment
,
);
final
Completer
<
void
>
stdoutDone
=
Completer
<
void
>();
final
Completer
<
void
>
stderrDone
=
Completer
<
void
>();
process
.
stdout
.
transform
<
String
>(
utf8
.
decoder
)
.
transform
<
String
>(
const
LineSplitter
())
.
listen
((
String
line
)
{
if
(
line
.
contains
(
'Reloaded '
))
{
process
.
stdin
.
writeln
(
'q'
);
}
print
(
'stdout:
$line
'
);
},
onDone:
()
{
stdoutDone
.
complete
();
});
process
.
stderr
.
transform
<
String
>(
utf8
.
decoder
)
.
transform
<
String
>(
const
LineSplitter
())
.
listen
((
String
line
)
{
print
(
'stderr:
$line
'
);
},
onDone:
()
{
stderrDone
.
complete
();
});
await
Future
.
wait
<
void
>(
<
Future
<
void
>>[
stdoutDone
.
future
,
stderrDone
.
future
]);
await
process
.
exitCode
;
freshRestartReloadsData
=
json
.
decode
(
benchmarkFile
.
readAsStringSync
())
as
Map
<
String
,
dynamic
>;
}
});
}
finally
{
flutterFrameworkSource
.
writeAsStringSync
(
oldContents
);
}
});
});
return
TaskResult
.
success
(
return
TaskResult
.
success
(
...
...
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