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
e2e313ec
Unverified
Commit
e2e313ec
authored
Mar 15, 2023
by
Jenn Magder
Committed by
GitHub
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take screenshot on devicelab failure (#122249)
Take screenshot on devicelab failure
parent
a599c08c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
16 deletions
+81
-16
gradle_plugin_light_apk_test.dart
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
+24
-12
utils.dart
dev/devicelab/lib/framework/utils.dart
+57
-4
No files found.
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
View file @
e2e313ec
...
@@ -252,10 +252,14 @@ Future<void> main() async {
...
@@ -252,10 +252,14 @@ Future<void> main() async {
section
(
'gradlew on build script with error'
);
section
(
'gradlew on build script with error'
);
await
project
.
introduceError
();
await
project
.
introduceError
();
ProcessResult
result
=
await
inDirectory
(
project
.
rootPath
,
()
{
ProcessResult
result
=
await
inDirectory
(
project
.
rootPath
,
()
{
return
executeFlutter
(
'build'
,
options:
<
String
>[
return
executeFlutter
(
'build'
,
options:
<
String
>[
'apk'
,
'apk'
,
'--release'
,
'--release'
,
]);
],
canFail:
true
,
);
});
});
if
(
result
.
exitCode
==
0
)
{
if
(
result
.
exitCode
==
0
)
{
...
@@ -278,10 +282,14 @@ Future<void> main() async {
...
@@ -278,10 +282,14 @@ Future<void> main() async {
section
(
'flutter build apk on build script with error'
);
section
(
'flutter build apk on build script with error'
);
await
project
.
introduceError
();
await
project
.
introduceError
();
result
=
await
inDirectory
(
project
.
rootPath
,
()
{
result
=
await
inDirectory
(
project
.
rootPath
,
()
{
return
executeFlutter
(
'build'
,
options:
<
String
>[
return
executeFlutter
(
'build'
,
options:
<
String
>[
'apk'
,
'apk'
,
'--release'
,
'--release'
,
]);
],
canFail:
true
,
);
});
});
if
(
result
.
exitCode
==
0
)
{
if
(
result
.
exitCode
==
0
)
{
throw
failure
(
throw
failure
(
...
@@ -304,10 +312,14 @@ Future<void> main() async {
...
@@ -304,10 +312,14 @@ Future<void> main() async {
section
(
'gradlew assembleDebug forwards stderr'
);
section
(
'gradlew assembleDebug forwards stderr'
);
await
project
.
introducePubspecError
();
await
project
.
introducePubspecError
();
final
ProcessResult
result
=
await
inDirectory
(
project
.
rootPath
,
()
{
final
ProcessResult
result
=
await
inDirectory
(
project
.
rootPath
,
()
{
return
executeFlutter
(
'build'
,
options:
<
String
>[
return
executeFlutter
(
'build'
,
options:
<
String
>[
'apk'
,
'apk'
,
'--release'
,
'--release'
,
]);
],
canFail:
true
,
);
});
});
if
(
result
.
exitCode
==
0
)
{
if
(
result
.
exitCode
==
0
)
{
throw
failure
(
throw
failure
(
...
...
dev/devicelab/lib/framework/utils.dart
View file @
e2e313ec
...
@@ -471,10 +471,15 @@ Future<int> flutter(String command, {
...
@@ -471,10 +471,15 @@ Future<int> flutter(String command, {
bool
canFail
=
false
,
// as in, whether failures are ok. False means that they are fatal.
bool
canFail
=
false
,
// as in, whether failures are ok. False means that they are fatal.
Map
<
String
,
String
>?
environment
,
Map
<
String
,
String
>?
environment
,
String
?
workingDirectory
,
String
?
workingDirectory
,
})
{
})
async
{
final
List
<
String
>
args
=
_flutterCommandArgs
(
command
,
options
);
final
List
<
String
>
args
=
_flutterCommandArgs
(
command
,
options
);
return
exec
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
final
int
exitCode
=
await
exec
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
canFail:
canFail
,
environment:
environment
,
workingDirectory:
workingDirectory
);
canFail:
canFail
,
environment:
environment
,
workingDirectory:
workingDirectory
);
if
(
exitCode
!=
0
&&
!
canFail
)
{
await
_flutterScreenshot
(
workingDirectory:
workingDirectory
);
}
return
exitCode
;
}
}
/// Starts a Flutter subprocess.
/// Starts a Flutter subprocess.
...
@@ -506,13 +511,20 @@ Future<Process> startFlutter(String command, {
...
@@ -506,13 +511,20 @@ Future<Process> startFlutter(String command, {
String
?
workingDirectory
,
String
?
workingDirectory
,
})
async
{
})
async
{
final
List
<
String
>
args
=
_flutterCommandArgs
(
command
,
options
);
final
List
<
String
>
args
=
_flutterCommandArgs
(
command
,
options
);
return
startProcess
(
final
Process
process
=
await
startProcess
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
args
,
environment:
environment
,
environment:
environment
,
isBot:
isBot
,
isBot:
isBot
,
workingDirectory:
workingDirectory
,
workingDirectory:
workingDirectory
,
);
);
unawaited
(
process
.
exitCode
.
then
<
void
>((
int
exitCode
)
async
{
if
(
exitCode
!=
0
)
{
await
_flutterScreenshot
(
workingDirectory:
workingDirectory
);
}
}));
return
process
;
}
}
/// Runs a `flutter` command and returns the standard output as a string.
/// Runs a `flutter` command and returns the standard output as a string.
...
@@ -530,12 +542,53 @@ Future<String> evalFlutter(String command, {
...
@@ -530,12 +542,53 @@ Future<String> evalFlutter(String command, {
Future
<
ProcessResult
>
executeFlutter
(
String
command
,
{
Future
<
ProcessResult
>
executeFlutter
(
String
command
,
{
List
<
String
>
options
=
const
<
String
>[],
List
<
String
>
options
=
const
<
String
>[],
bool
canFail
=
false
,
// as in, whether failures are ok. False means that they are fatal.
})
async
{
})
async
{
final
List
<
String
>
args
=
_flutterCommandArgs
(
command
,
options
);
final
List
<
String
>
args
=
_flutterCommandArgs
(
command
,
options
);
return
_processManager
.
run
(
final
ProcessResult
processResult
=
await
_processManager
.
run
(
<
String
>[
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
...
args
],
<
String
>[
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
...
args
],
workingDirectory:
cwd
,
workingDirectory:
cwd
,
);
);
if
(
processResult
.
exitCode
!=
0
&&
!
canFail
)
{
await
_flutterScreenshot
();
}
return
processResult
;
}
Future
<
void
>
_flutterScreenshot
({
String
?
workingDirectory
})
async
{
try
{
final
Directory
?
dumpDirectory
=
hostAgent
.
dumpDirectory
;
if
(
dumpDirectory
==
null
)
{
return
;
}
// On command failure try uploading screenshot of failing command.
final
String
screenshotPath
=
path
.
join
(
dumpDirectory
.
path
,
'device-screenshot-
${DateTime.now().toLocal().toIso8601String()}
.png'
,
);
final
String
deviceId
=
(
await
devices
.
workingDevice
).
deviceId
;
print
(
'Taking screenshot of working device
$deviceId
at
$screenshotPath
'
);
final
List
<
String
>
args
=
_flutterCommandArgs
(
'screenshot'
,
<
String
>[
'--out'
,
screenshotPath
,
'-d'
,
deviceId
,
],
);
final
ProcessResult
screenshot
=
await
_processManager
.
run
(
<
String
>[
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
...
args
],
workingDirectory:
workingDirectory
??
cwd
,
);
if
(
screenshot
.
exitCode
!=
0
)
{
print
(
'Failed to take screenshot. Continuing.'
);
}
}
catch
(
exception
)
{
print
(
'Failed to take screenshot. Continuing.
\n
$exception
'
);
}
}
}
String
get
dartBin
=>
String
get
dartBin
=>
...
...
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