Commit eb2ce029 authored by Bo Yang's avatar Bo Yang

Fix absolute/relative path in output

parent e2555e23
...@@ -1344,7 +1344,11 @@ bool CommandLineInterface::GenerateDependencyManifestFile( ...@@ -1344,7 +1344,11 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
vector<string> relative_output_filenames; vector<string> relative_output_filenames;
directory->GetOutputFilenames(&relative_output_filenames); directory->GetOutputFilenames(&relative_output_filenames);
for (int i = 0; i < relative_output_filenames.size(); i++) { for (int i = 0; i < relative_output_filenames.size(); i++) {
output_filenames.push_back(location + relative_output_filenames[i]); string output_filename = location + relative_output_filenames[i];
if (output_filename.compare(0, 2, "./") == 0) {
output_filename = output_filename.substr(2);
}
output_filenames.push_back(output_filename);
} }
} }
......
...@@ -988,17 +988,22 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) { ...@@ -988,17 +988,22 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) {
" optional Foo foo = 1;\n" " optional Foo foo = 1;\n"
"}\n"); "}\n");
Run("protocol_compiler --dependency_out=$tmpdir/manifest " string current_working_directory = get_current_dir_name();
"--test_out=$tmpdir --proto_path=$tmpdir bar.proto"); SwitchToTempDirectory();
Run("protocol_compiler --dependency_out=manifest --test_out=. "
"bar.proto");
ExpectNoErrors(); ExpectNoErrors();
ExpectFileContent("manifest", ExpectFileContent("manifest",
"$tmpdir/bar.proto.MockCodeGenerator.test_generator: " "bar.proto.MockCodeGenerator.test_generator: "
"$tmpdir/foo.proto\\\n $tmpdir/bar.proto"); "foo.proto\\\n bar.proto");
File::ChangeWorkingDirectory(current_working_directory);
} }
TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForRelativePath) { TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForAbsolutePath) {
CreateTempFile("foo.proto", CreateTempFile("foo.proto",
"syntax = \"proto2\";\n" "syntax = \"proto2\";\n"
"message Foo {}\n"); "message Foo {}\n");
...@@ -1009,10 +1014,7 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForRelativePath) { ...@@ -1009,10 +1014,7 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForRelativePath) {
" optional Foo foo = 1;\n" " optional Foo foo = 1;\n"
"}\n"); "}\n");
string current_working_directory = get_current_dir_name(); Run("protocol_compiler --dependency_out=$tmpdir/manifest "
SwitchToTempDirectory();
Run("protocol_compiler --dependency_out=manifest "
"--test_out=$tmpdir --proto_path=$tmpdir bar.proto"); "--test_out=$tmpdir --proto_path=$tmpdir bar.proto");
ExpectNoErrors(); ExpectNoErrors();
...@@ -1020,8 +1022,6 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForRelativePath) { ...@@ -1020,8 +1022,6 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForRelativePath) {
ExpectFileContent("manifest", ExpectFileContent("manifest",
"$tmpdir/bar.proto.MockCodeGenerator.test_generator: " "$tmpdir/bar.proto.MockCodeGenerator.test_generator: "
"$tmpdir/foo.proto\\\n $tmpdir/bar.proto"); "$tmpdir/foo.proto\\\n $tmpdir/bar.proto");
File::ChangeWorkingDirectory(current_working_directory);
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment