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
9c1a87e6
Unverified
Commit
9c1a87e6
authored
Nov 08, 2021
by
Alex
Committed by
GitHub
Nov 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added cleanContext (#93264)
* added cleanContext * using async * added one more test
parent
550281e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
+42
-12
clean.dart
dev/conductor/core/lib/src/clean.dart
+22
-5
clean_test.dart
dev/conductor/core/test/clean_test.dart
+20
-7
No files found.
dev/conductor/core/lib/src/clean.dart
View file @
9c1a87e6
...
...
@@ -49,12 +49,11 @@ class CleanCommand extends Command<void> {
'This will abort a work in progress release.'
;
@override
void
run
()
{
Future
<
void
>
run
()
{
final
ArgResults
argumentResults
=
argResults
!;
final
File
stateFile
=
checkouts
.
fileSystem
.
file
(
argumentResults
[
kStateOption
]);
if
(!
stateFile
.
existsSync
())
{
throw
ConductorException
(
'No persistent state file found at
${stateFile.path}
!'
);
throw
ConductorException
(
'No persistent state file found at
${stateFile.path}
!'
);
}
if
(!(
argumentResults
[
kYesFlag
]
as
bool
))
{
...
...
@@ -67,10 +66,28 @@ class CleanCommand extends Command<void> {
// Only proceed if the first character of stdin is 'y' or 'Y'
if
(
response
.
isEmpty
||
response
[
0
].
toLowerCase
()
!=
'y'
)
{
stdio
.
printStatus
(
'Aborting clean operation.'
);
return
;
}
}
stdio
.
printStatus
(
'Deleting persistent state file
${stateFile.path}
...'
);
stateFile
.
deleteSync
();
final
RunContext
context
=
RunContext
(
stateFile:
stateFile
,
);
return
context
.
run
();
}
}
/// Context for cleaning up persistent state file.
///
/// This is a frontend-agnostic implementation.
class
RunContext
{
RunContext
({
required
this
.
stateFile
,
});
final
File
stateFile
;
Future
<
void
>
run
()
{
return
stateFile
.
delete
();
}
}
dev/conductor/core/test/clean_test.dart
View file @
9c1a87e6
...
...
@@ -15,6 +15,7 @@ void main() {
group
(
'clean command'
,
()
{
const
String
flutterRoot
=
'/flutter'
;
const
String
checkoutsParentDirectory
=
'
$flutterRoot
/dev/tools/'
;
const
String
stateFilePath
=
'/state-file.json'
;
late
MemoryFileSystem
fileSystem
;
late
FakePlatform
platform
;
...
...
@@ -47,24 +48,36 @@ void main() {
});
test
(
'throws if no state file found'
,
()
async
{
const
String
stateFile
=
'/state-file.json'
;
await
expectLater
(
()
async
=>
runner
.
run
(<
String
>[
'clean'
,
'--
$kStateOption
'
,
stateFile
,
stateFile
Path
,
'--
$kYesFlag
'
,
]),
throwsExceptionWith
(
'No persistent state file found at
$stateFile
'
,
'No persistent state file found at
$stateFile
Path
'
,
),
);
});
test
(
'deletes state file'
,
()
async
{
final
File
stateFile
=
fileSystem
.
file
(
'/state-file.json'
);
stateFile
.
writeAsStringSync
(
'{}'
);
test
(
'deletes an empty state file'
,
()
async
{
final
File
stateFile
=
fileSystem
.
file
(
stateFilePath
);
stateFile
.
writeAsStringSync
(
''
);
await
runner
.
run
(<
String
>[
'clean'
,
'--
$kStateOption
'
,
stateFile
.
path
,
'--
$kYesFlag
'
,
]);
expect
(
stateFile
.
existsSync
(),
false
);
});
test
(
'deletes a state file with content'
,
()
async
{
final
File
stateFile
=
fileSystem
.
file
(
stateFilePath
);
stateFile
.
writeAsStringSync
(
'{status: pending}'
);
await
runner
.
run
(<
String
>[
'clean'
,
...
...
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