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
2565062d
Unverified
Commit
2565062d
authored
Dec 08, 2020
by
Casey Hillers
Committed by
GitHub
Dec 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git branch flag (#71886)
parent
c88ab79b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
32 deletions
+31
-32
run.dart
dev/devicelab/bin/run.dart
+10
-1
cocoon.dart
dev/devicelab/lib/framework/cocoon.dart
+6
-15
cocoon_test.dart
dev/devicelab/test/cocoon_test.dart
+15
-16
No files found.
dev/devicelab/bin/run.dart
View file @
2565062d
...
...
@@ -22,6 +22,9 @@ List<String> _taskNames = <String>[];
/// The device-id to run test on.
String
deviceId
;
/// The git branch being tested on.
String
gitBranch
;
/// The build of the local engine to use.
///
/// Required for A/B test mode.
...
...
@@ -88,6 +91,7 @@ Future<void> main(List<String> rawArgs) async {
deviceId
=
args
[
'device-id'
]
as
String
;
exitOnFirstTestFailure
=
args
[
'exit'
]
as
bool
;
gitBranch
=
args
[
'git-branch'
]
as
String
;
localEngine
=
args
[
'local-engine'
]
as
String
;
localEngineSrcPath
=
args
[
'local-engine-src-path'
]
as
String
;
luciBuilder
=
args
[
'luci-builder'
]
as
String
;
...
...
@@ -119,7 +123,7 @@ Future<void> _runTasks() async {
if
(
serviceAccountTokenFile
!=
null
)
{
final
Cocoon
cocoon
=
Cocoon
(
serviceAccountTokenPath:
serviceAccountTokenFile
);
/// Cocoon references LUCI tasks by the [luciBuilder] instead of [taskName].
await
cocoon
.
sendTaskResult
(
builderName:
luciBuilder
,
result:
result
);
await
cocoon
.
sendTaskResult
(
builderName:
luciBuilder
,
result:
result
,
gitBranch:
gitBranch
);
}
if
(!
result
.
succeeded
)
{
...
...
@@ -326,6 +330,11 @@ final ArgParser _argParser = ArgParser()
defaultsTo:
true
,
help:
'Exit on the first test failure.'
,
)
..
addOption
(
'git-branch'
,
help:
'[Flutter infrastructure] Git branch of the current commit. LUCI
\n
'
'checkouts run in detached HEAD state, so the branch must be passed.'
,
)
..
addOption
(
'local-engine'
,
help:
'Name of a build output within the engine out directory, if you
\n
'
...
...
dev/devicelab/lib/framework/cocoon.dart
View file @
2565062d
...
...
@@ -48,9 +48,6 @@ class Cocoon {
static
final
Logger
logger
=
Logger
(
'CocoonClient'
);
String
get
commitBranch
=>
_commitBranch
??
_readCommitBranch
();
String
_commitBranch
;
String
get
commitSha
=>
_commitSha
??
_readCommitSha
();
String
_commitSha
;
...
...
@@ -64,18 +61,12 @@ class Cocoon {
return
_commitSha
=
result
.
stdout
as
String
;
}
/// Parse the local repo for the current running branch.
String
_readCommitBranch
()
{
final
ProcessResult
result
=
processRunSync
(
'git'
,
<
String
>[
'rev-parse'
,
'--abbrev-ref'
,
'HEAD'
]);
if
(
result
.
exitCode
!=
0
)
{
throw
CocoonException
(
result
.
stderr
as
String
);
}
return
_commitBranch
=
result
.
stdout
as
String
;
}
/// Send [TaskResult] to Cocoon.
Future
<
void
>
sendTaskResult
({
String
builderName
,
TaskResult
result
})
async
{
Future
<
void
>
sendTaskResult
({
@required
String
builderName
,
@required
TaskResult
result
,
@required
String
gitBranch
})
async
{
assert
(
builderName
!=
null
);
assert
(
gitBranch
!=
null
);
assert
(
result
!=
null
);
// Skip logging on test runs
Logger
.
root
.
level
=
Level
.
ALL
;
Logger
.
root
.
onRecord
.
listen
((
LogRecord
rec
)
{
...
...
@@ -83,7 +74,7 @@ class Cocoon {
});
final
Map
<
String
,
dynamic
>
status
=
<
String
,
dynamic
>{
'CommitBranch'
:
comm
itBranch
,
'CommitBranch'
:
g
itBranch
,
'CommitSha'
:
commitSha
,
'BuilderName'
:
builderName
,
'NewStatus'
:
result
.
succeeded
?
'Succeeded'
:
'Failed'
,
...
...
dev/devicelab/test/cocoon_test.dart
View file @
2565062d
...
...
@@ -27,7 +27,6 @@ void main() {
_processResult
;
// Expected test values.
const
String
commitBranch
=
'flutter-1.23-candidate.18'
;
const
String
commitSha
=
'a4952838bf288a81d8ea11edfd4b4cd649fa94cc'
;
const
String
serviceAccountTokenPath
=
'test_account_file'
;
const
String
serviceAccountToken
=
'test_token'
;
...
...
@@ -45,18 +44,6 @@ void main() {
serviceAccountFile
.
writeAsStringSync
(
serviceAccountToken
);
});
test
(
'returns expected commit branch'
,
()
{
_processResult
=
ProcessResult
(
1
,
0
,
commitBranch
,
''
);
cocoon
=
Cocoon
(
serviceAccountTokenPath:
serviceAccountTokenPath
,
filesystem:
fs
,
httpClient:
mockClient
,
processRunSync:
runSyncStub
,
);
expect
(
cocoon
.
commitBranch
,
commitBranch
);
});
test
(
'returns expected commit sha'
,
()
{
_processResult
=
ProcessResult
(
1
,
0
,
commitSha
,
''
);
cocoon
=
Cocoon
(
...
...
@@ -78,7 +65,6 @@ void main() {
processRunSync:
runSyncStub
,
);
expect
(()
=>
cocoon
.
commitBranch
,
throwsA
(
isA
<
CocoonException
>()));
expect
(()
=>
cocoon
.
commitSha
,
throwsA
(
isA
<
CocoonException
>()));
});
...
...
@@ -93,7 +79,7 @@ void main() {
final
TaskResult
result
=
TaskResult
.
success
(<
String
,
dynamic
>{});
// This should not throw an error.
await
cocoon
.
sendTaskResult
(
builderName:
'builderAbc'
,
result:
result
);
await
cocoon
.
sendTaskResult
(
builderName:
'builderAbc'
,
gitBranch:
'branchAbc'
,
result:
result
);
});
test
(
'throws client exception on non-200 responses'
,
()
async
{
...
...
@@ -106,7 +92,20 @@ void main() {
);
final
TaskResult
result
=
TaskResult
.
success
(<
String
,
dynamic
>{});
expect
(()
=>
cocoon
.
sendTaskResult
(
builderName:
'builderAbc'
,
result:
result
),
throwsA
(
isA
<
ClientException
>()));
expect
(()
=>
cocoon
.
sendTaskResult
(
builderName:
'builderAbc'
,
gitBranch:
'branchAbc'
,
result:
result
),
throwsA
(
isA
<
ClientException
>()));
});
test
(
'null git branch throws error'
,
()
async
{
mockClient
=
MockClient
((
Request
request
)
async
=>
Response
(
''
,
500
));
cocoon
=
Cocoon
(
serviceAccountTokenPath:
serviceAccountTokenPath
,
filesystem:
fs
,
httpClient:
mockClient
,
);
final
TaskResult
result
=
TaskResult
.
success
(<
String
,
dynamic
>{});
expect
(()
=>
cocoon
.
sendTaskResult
(
builderName:
'builderAbc'
,
gitBranch:
null
,
result:
result
),
throwsA
(
isA
<
AssertionError
>()));
});
});
...
...
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