diff options
author | Xin Li <delphij@google.com> | 2020-08-31 21:21:38 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2020-08-31 21:21:38 -0700 |
commit | 628590d7ec80e10a3fc24b1c18a1afb55cca10a8 (patch) | |
tree | 4b1c3f52d86d7fb53afbe9e9438468588fa489f8 /tools/aapt2/test/Fixture.cpp | |
parent | b11b8ec3aec8bb42f2c07e1c5ac7942da293baa8 (diff) | |
parent | d2d3a20624d968199353ccf6ddbae6f3ac39c9af (diff) |
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
Diffstat (limited to 'tools/aapt2/test/Fixture.cpp')
-rw-r--r-- | tools/aapt2/test/Fixture.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/aapt2/test/Fixture.cpp b/tools/aapt2/test/Fixture.cpp index a51b4a4649f1..5386802dbc8e 100644 --- a/tools/aapt2/test/Fixture.cpp +++ b/tools/aapt2/test/Fixture.cpp @@ -80,7 +80,7 @@ void TestDirectoryFixture::TearDown() { ClearDirectory(temp_dir_); } -bool TestDirectoryFixture::WriteFile(const std::string& path, const std::string& contents) { +void TestDirectoryFixture::WriteFile(const std::string& path, const std::string& contents) { CHECK(util::StartsWith(path, temp_dir_)) << "Attempting to create a file outside of test temporary directory."; @@ -91,16 +91,31 @@ bool TestDirectoryFixture::WriteFile(const std::string& path, const std::string& file::mkdirs(dirs); } - return android::base::WriteStringToFile(contents, path); + CHECK(android::base::WriteStringToFile(contents, path)); } bool CommandTestFixture::CompileFile(const std::string& path, const std::string& contents, const android::StringPiece& out_dir, IDiagnostics* diag) { - CHECK(WriteFile(path, contents)); + WriteFile(path, contents); CHECK(file::mkdirs(out_dir.data())); return CompileCommand(diag).Execute({path, "-o", out_dir, "-v"}, &std::cerr) == 0; } +bool CommandTestFixture::Link(const std::vector<std::string>& args, IDiagnostics* diag) { + std::vector<android::StringPiece> link_args; + for(const std::string& arg : args) { + link_args.emplace_back(arg); + } + + // Link against the android SDK + std::string android_sdk = file::BuildPath({android::base::GetExecutableDirectory(), + "integration-tests", "CommandTests", + "android-28.jar"}); + link_args.insert(link_args.end(), {"-I", android_sdk}); + + return LinkCommand(diag).Execute(link_args, &std::cerr) == 0; +} + bool CommandTestFixture::Link(const std::vector<std::string>& args, const android::StringPiece& flat_dir, IDiagnostics* diag) { std::vector<android::StringPiece> link_args; @@ -128,10 +143,10 @@ bool CommandTestFixture::Link(const std::vector<std::string>& args, std::string CommandTestFixture::GetDefaultManifest(const char* package_name) { const std::string manifest_file = GetTestPath("AndroidManifest.xml"); - CHECK(WriteFile(manifest_file, android::base::StringPrintf(R"( + WriteFile(manifest_file, android::base::StringPrintf(R"( <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="%s"> - </manifest>)", package_name))); + </manifest>)", package_name)); return manifest_file; } |