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
404bb5a5
Unverified
Commit
404bb5a5
authored
Mar 24, 2020
by
Jenn Magder
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert analyze_test to testWithoutContext (#53141)
parent
f3d95cd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
27 deletions
+20
-27
analyze_test.dart
...tter_tools/test/commands.shard/hermetic/analyze_test.dart
+20
-27
No files found.
packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart
View file @
404bb5a5
...
@@ -5,30 +5,11 @@
...
@@ -5,30 +5,11 @@
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
const
String
_kFlutterRoot
=
'/data/flutter'
;
const
String
_kFlutterRoot
=
'/data/flutter'
;
/// Return true if [fileList] contains a path that resides inside the Flutter repository.
/// If [fileList] is empty, then return true if the current directory resides inside the Flutter repository.
bool
inRepo
(
List
<
String
>
fileList
)
{
if
(
fileList
==
null
||
fileList
.
isEmpty
)
{
fileList
=
<
String
>[
globals
.
fs
.
path
.
current
];
}
final
String
root
=
globals
.
fs
.
path
.
normalize
(
globals
.
fs
.
path
.
absolute
(
Cache
.
flutterRoot
));
final
String
prefix
=
root
+
globals
.
fs
.
path
.
separator
;
for
(
String
file
in
fileList
)
{
file
=
globals
.
fs
.
path
.
normalize
(
globals
.
fs
.
path
.
absolute
(
file
));
if
(
file
==
root
||
file
.
startsWith
(
prefix
))
{
return
true
;
}
}
return
false
;
}
void
main
(
)
{
void
main
(
)
{
FileSystem
fs
;
FileSystem
fs
;
Directory
tempDir
;
Directory
tempDir
;
...
@@ -45,27 +26,39 @@ void main() {
...
@@ -45,27 +26,39 @@ void main() {
});
});
group
(
'analyze'
,
()
{
group
(
'analyze'
,
()
{
testUsingContext
(
'inRepo'
,
()
{
testWithoutContext
(
'inRepo'
,
()
{
bool
inRepo
(
List
<
String
>
fileList
)
{
if
(
fileList
==
null
||
fileList
.
isEmpty
)
{
fileList
=
<
String
>[
fs
.
path
.
current
];
}
final
String
root
=
fs
.
path
.
normalize
(
fs
.
path
.
absolute
(
Cache
.
flutterRoot
));
final
String
prefix
=
root
+
fs
.
path
.
separator
;
for
(
String
file
in
fileList
)
{
file
=
fs
.
path
.
normalize
(
fs
.
path
.
absolute
(
file
));
if
(
file
==
root
||
file
.
startsWith
(
prefix
))
{
return
true
;
}
}
return
false
;
}
// Absolute paths
// Absolute paths
expect
(
inRepo
(<
String
>[
tempDir
.
path
]),
isFalse
);
expect
(
inRepo
(<
String
>[
tempDir
.
path
]),
isFalse
);
expect
(
inRepo
(<
String
>[
globals
.
fs
.
path
.
join
(
tempDir
.
path
,
'foo'
)]),
isFalse
);
expect
(
inRepo
(<
String
>[
fs
.
path
.
join
(
tempDir
.
path
,
'foo'
)]),
isFalse
);
expect
(
inRepo
(<
String
>[
Cache
.
flutterRoot
]),
isTrue
);
expect
(
inRepo
(<
String
>[
Cache
.
flutterRoot
]),
isTrue
);
expect
(
inRepo
(<
String
>[
globals
.
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'foo'
)]),
isTrue
);
expect
(
inRepo
(<
String
>[
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'foo'
)]),
isTrue
);
// Relative paths
// Relative paths
globals
.
fs
.
currentDirectory
=
Cache
.
flutterRoot
;
fs
.
currentDirectory
=
Cache
.
flutterRoot
;
expect
(
inRepo
(<
String
>[
'.'
]),
isTrue
);
expect
(
inRepo
(<
String
>[
'.'
]),
isTrue
);
expect
(
inRepo
(<
String
>[
'foo'
]),
isTrue
);
expect
(
inRepo
(<
String
>[
'foo'
]),
isTrue
);
globals
.
fs
.
currentDirectory
=
tempDir
.
path
;
fs
.
currentDirectory
=
tempDir
.
path
;
expect
(
inRepo
(<
String
>[
'.'
]),
isFalse
);
expect
(
inRepo
(<
String
>[
'.'
]),
isFalse
);
expect
(
inRepo
(<
String
>[
'foo'
]),
isFalse
);
expect
(
inRepo
(<
String
>[
'foo'
]),
isFalse
);
// Ensure no exceptions
// Ensure no exceptions
inRepo
(
null
);
inRepo
(
null
);
inRepo
(<
String
>[]);
inRepo
(<
String
>[]);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
});
});
});
}
}
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