Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
438d2e20
Commit
438d2e20
authored
1 year ago
by
Mark Punzalan
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "[aapt2] Allow multi-line argument files" into main
parents
5d201fd4
8c4d4ea3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/aapt2/util/Files.cpp
+12
-6
12 additions, 6 deletions
tools/aapt2/util/Files.cpp
tools/aapt2/util/Files_test.cpp
+42
-1
42 additions, 1 deletion
tools/aapt2/util/Files_test.cpp
with
54 additions
and
7 deletions
tools/aapt2/util/Files.cpp
+
12
−
6
View file @
438d2e20
...
...
@@ -251,10 +251,13 @@ bool AppendArgsFromFile(StringPiece path, std::vector<std::string>* out_arglist,
return
false
;
}
for
(
StringPiece
line
:
util
::
Tokenize
(
contents
,
'
'
))
{
for
(
StringPiece
line
:
util
::
Tokenize
(
contents
,
'
\n
'
))
{
line
=
util
::
TrimWhitespace
(
line
);
if
(
!
line
.
empty
())
{
out_arglist
->
emplace_back
(
line
);
for
(
StringPiece
arg
:
util
::
Tokenize
(
line
,
' '
))
{
arg
=
util
::
TrimWhitespace
(
arg
);
if
(
!
arg
.
empty
())
{
out_arglist
->
emplace_back
(
arg
);
}
}
}
return
true
;
...
...
@@ -270,10 +273,13 @@ bool AppendSetArgsFromFile(StringPiece path, std::unordered_set<std::string>* ou
return
false
;
}
for
(
StringPiece
line
:
util
::
Tokenize
(
contents
,
'
'
))
{
for
(
StringPiece
line
:
util
::
Tokenize
(
contents
,
'
\n
'
))
{
line
=
util
::
TrimWhitespace
(
line
);
if
(
!
line
.
empty
())
{
out_argset
->
emplace
(
line
);
for
(
StringPiece
arg
:
util
::
Tokenize
(
line
,
' '
))
{
arg
=
util
::
TrimWhitespace
(
arg
);
if
(
!
arg
.
empty
())
{
out_argset
->
emplace
(
arg
);
}
}
}
return
true
;
...
...
This diff is collapsed.
Click to expand it.
tools/aapt2/util/Files_test.cpp
+
42
−
1
View file @
438d2e20
...
...
@@ -25,6 +25,9 @@
using
::
android
::
base
::
StringPrintf
;
using
::
testing
::
ElementsAre
;
using
::
testing
::
UnorderedElementsAre
;
namespace
aapt
{
namespace
file
{
...
...
@@ -34,9 +37,11 @@ constexpr const char sTestDirSep = '\\';
constexpr
const
char
sTestDirSep
=
'/'
;
#endif
class
FilesTest
:
public
::
testing
::
Test
{
class
FilesTest
:
public
TestDirectoryFixture
{
public:
void
SetUp
()
override
{
TestDirectoryFixture
::
SetUp
();
std
::
stringstream
builder
;
builder
<<
"hello"
<<
sDirSep
<<
"there"
;
expected_path_
=
builder
.
str
();
...
...
@@ -66,6 +71,42 @@ TEST_F(FilesTest, AppendPathWithLeadingOrTrailingSeparators) {
EXPECT_EQ
(
expected_path_
,
base
);
}
TEST_F
(
FilesTest
,
AppendArgsFromFile
)
{
const
std
::
string
args_file
=
GetTestPath
(
"args.txt"
);
WriteFile
(
args_file
,
"
\n
"
"arg1 arg2 arg3
\n
"
" arg4 arg5"
);
std
::
vector
<
std
::
string
>
args
;
std
::
string
error
;
ASSERT_TRUE
(
AppendArgsFromFile
(
args_file
,
&
args
,
&
error
));
EXPECT_THAT
(
args
,
ElementsAre
(
"arg1"
,
"arg2"
,
"arg3"
,
"arg4"
,
"arg5"
));
}
TEST_F
(
FilesTest
,
AppendArgsFromFile_InvalidFile
)
{
std
::
vector
<
std
::
string
>
args
;
std
::
string
error
;
ASSERT_FALSE
(
AppendArgsFromFile
(
GetTestPath
(
"not_found.txt"
),
&
args
,
&
error
));
}
TEST_F
(
FilesTest
,
AppendSetArgsFromFile
)
{
const
std
::
string
args_file
=
GetTestPath
(
"args.txt"
);
WriteFile
(
args_file
,
"
\n
"
"arg2 arg4 arg1
\n
"
" arg5 arg3"
);
std
::
unordered_set
<
std
::
string
>
args
;
std
::
string
error
;
ASSERT_TRUE
(
AppendSetArgsFromFile
(
args_file
,
&
args
,
&
error
));
EXPECT_THAT
(
args
,
UnorderedElementsAre
(
"arg1"
,
"arg2"
,
"arg3"
,
"arg4"
,
"arg5"
));
}
TEST_F
(
FilesTest
,
AppendSetArgsFromFile_InvalidFile
)
{
std
::
unordered_set
<
std
::
string
>
args
;
std
::
string
error
;
ASSERT_FALSE
(
AppendSetArgsFromFile
(
GetTestPath
(
"not_found.txt"
),
&
args
,
&
error
));
}
#ifdef _WIN32
TEST_F
(
FilesTest
,
WindowsMkdirsLongPath
)
{
// Creating directory paths longer than the Windows maximum path length (260 charatcers) should
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment