| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "tools/gn/analyzer.h" | 6 #include "tools/gn/analyzer.h" |
| 7 #include "tools/gn/build_settings.h" | 7 #include "tools/gn/build_settings.h" |
| 8 #include "tools/gn/builder.h" | 8 #include "tools/gn/builder.h" |
| 9 #include "tools/gn/loader.h" | 9 #include "tools/gn/loader.h" |
| 10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace | 115 } // namespace |
| 116 | 116 |
| 117 // TODO: clean this up when raw string literals are allowed. | 117 // TODO: clean this up when raw string literals are allowed. |
| 118 | 118 |
| 119 TEST_F(AnalyzerTest, AllWasPruned) { | 119 TEST_F(AnalyzerTest, AllWasPruned) { |
| 120 RunBasicTest( | 120 RunBasicTest( |
| 121 "{" | 121 "{" |
| 122 " \"files\": [ \"//d/b.cc\" ]," | 122 " \"files\": [ \"//d/b.cc\" ]," |
| 123 " \"compile_targets\": [ \"all\" ]," | 123 " \"additional_compile_targets\": [ \"all\" ]," |
| 124 " \"test_targets\": [ ]" | 124 " \"test_targets\": [ ]" |
| 125 "}", | 125 "}", |
| 126 "{" | 126 "{" |
| 127 "\"compile_targets\":[\"//d:b_unittests\",\"//d:c\"]," | 127 "\"compile_targets\":[\"//d:b_unittests\",\"//d:c\"]," |
| 128 "\"status\":\"Found dependency\"," | 128 "\"status\":\"Found dependency\"," |
| 129 "\"test_targets\":[]" | 129 "\"test_targets\":[]" |
| 130 "}"); | 130 "}"); |
| 131 } | 131 } |
| 132 | 132 |
| 133 TEST_F(AnalyzerTest, NoDependency) { | 133 TEST_F(AnalyzerTest, NoDependency) { |
| 134 RunBasicTest( | 134 RunBasicTest( |
| 135 "{" | 135 "{" |
| 136 " \"files\":[ \"//missing.cc\" ]," | 136 " \"files\":[ \"//missing.cc\" ]," |
| 137 " \"compile_targets\": [ \"all\" ]," | 137 " \"additional_compile_targets\": [ \"all\" ]," |
| 138 " \"test_targets\": [ \"//:a\" ]" | 138 " \"test_targets\": [ \"//:a\" ]" |
| 139 "}", | 139 "}", |
| 140 "{" | 140 "{" |
| 141 "\"compile_targets\":[]," | 141 "\"compile_targets\":[]," |
| 142 "\"status\":\"No dependency\"," | 142 "\"status\":\"No dependency\"," |
| 143 "\"test_targets\":[]" | 143 "\"test_targets\":[]" |
| 144 "}"); | 144 "}"); |
| 145 } | 145 } |
| 146 | 146 |
| 147 TEST_F(AnalyzerTest, NoFilesNoTargets) { | 147 TEST_F(AnalyzerTest, NoFilesNoTargets) { |
| 148 RunBasicTest( | 148 RunBasicTest( |
| 149 "{" | 149 "{" |
| 150 " \"files\": []," | 150 " \"files\": []," |
| 151 " \"compile_targets\": []," | 151 " \"additional_compile_targets\": []," |
| 152 " \"test_targets\": []" | 152 " \"test_targets\": []" |
| 153 "}", | 153 "}", |
| 154 "{" | 154 "{" |
| 155 "\"compile_targets\":[]," | 155 "\"compile_targets\":[]," |
| 156 "\"status\":\"No dependency\"," | 156 "\"status\":\"No dependency\"," |
| 157 "\"test_targets\":[]" | 157 "\"test_targets\":[]" |
| 158 "}"); | 158 "}"); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST_F(AnalyzerTest, OneTestTargetModified) { | 161 TEST_F(AnalyzerTest, OneTestTargetModified) { |
| 162 RunBasicTest( | 162 RunBasicTest( |
| 163 "{" | 163 "{" |
| 164 " \"files\": [ \"//a.cc\" ]," | 164 " \"files\": [ \"//a.cc\" ]," |
| 165 " \"compile_targets\": []," | 165 " \"additional_compile_targets\": []," |
| 166 " \"test_targets\": [ \"//:a\" ]" | 166 " \"test_targets\": [ \"//:a\" ]" |
| 167 "}", | 167 "}", |
| 168 "{" | 168 "{" |
| 169 "\"compile_targets\":[]," | 169 "\"compile_targets\":[]," |
| 170 "\"status\":\"Found dependency\"," | 170 "\"status\":\"Found dependency\"," |
| 171 "\"test_targets\":[\"//:a\"]" | 171 "\"test_targets\":[\"//:a\"]" |
| 172 "}"); | 172 "}"); |
| 173 } | 173 } |
| 174 |
| 175 TEST_F(AnalyzerTest, FilesArentSourceAbsolute) { |
| 176 RunBasicTest( |
| 177 "{" |
| 178 " \"files\": [ \"a.cc\" ]," |
| 179 " \"additional_compile_targets\": []," |
| 180 " \"test_targets\": [ \"//:a\" ]" |
| 181 "}", |
| 182 "{" |
| 183 "\"error\":" |
| 184 "\"\\\"a.cc\\\" is not a source-absolute or absolute path.\"," |
| 185 "\"invalid_targets\":[]" |
| 186 "}"); |
| 187 } |
| 188 |
| 189 TEST_F(AnalyzerTest, WrongInputFields) { |
| 190 RunBasicTest( |
| 191 "{" |
| 192 " \"files\": [ \"//a.cc\" ]," |
| 193 " \"compile_targets\": []," |
| 194 " \"test_targets\": [ \"//:a\" ]" |
| 195 "}", |
| 196 "{" |
| 197 "\"error\":" |
| 198 "\"Input does not have a key named " |
| 199 "\\\"additional_compile_targets\\\" with a list value.\"," |
| 200 "\"invalid_targets\":[]" |
| 201 "}"); |
| 202 } |
| OLD | NEW |