Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Side by Side Diff: third_party/protobuf/conformance/conformance_test_runner.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 fprintf(stderr, "\n"); 244 fprintf(stderr, "\n");
245 fprintf(stderr, "Options:\n"); 245 fprintf(stderr, "Options:\n");
246 fprintf(stderr, 246 fprintf(stderr,
247 " --failure_list <filename> Use to specify list of tests\n"); 247 " --failure_list <filename> Use to specify list of tests\n");
248 fprintf(stderr, 248 fprintf(stderr,
249 " that are expected to fail. File\n"); 249 " that are expected to fail. File\n");
250 fprintf(stderr, 250 fprintf(stderr,
251 " should contain one test name per\n"); 251 " should contain one test name per\n");
252 fprintf(stderr, 252 fprintf(stderr,
253 " line. Use '#' for comments.\n"); 253 " line. Use '#' for comments.\n");
254 fprintf(stderr,
255 " --enforce_recommended Enforce that recommended test\n");
256 fprintf(stderr,
257 " cases are also passing. Specify\n");
258 fprintf(stderr,
259 " this flag if you want to be\n");
260 fprintf(stderr,
261 " strictly conforming to protobuf\n");
262 fprintf(stderr,
263 " spec.\n");
254 exit(1); 264 exit(1);
255 } 265 }
256 266
257 void ParseFailureList(const char *filename, vector<string>* failure_list) { 267 void ParseFailureList(const char *filename, vector<string>* failure_list) {
258 std::ifstream infile(filename); 268 std::ifstream infile(filename);
259 269
260 if (!infile.is_open()) { 270 if (!infile.is_open()) {
261 fprintf(stderr, "Couldn't open failure list file: %s\n", filename); 271 fprintf(stderr, "Couldn't open failure list file: %s\n", filename);
262 exit(1); 272 exit(1);
263 } 273 }
264 274
265 for (string line; getline(infile, line);) { 275 for (string line; getline(infile, line);) {
266 // Remove whitespace. 276 // Remove whitespace.
267 line.erase(std::remove_if(line.begin(), line.end(), ::isspace), 277 line.erase(std::remove_if(line.begin(), line.end(), ::isspace),
268 line.end()); 278 line.end());
269 279
270 // Remove comments. 280 // Remove comments.
271 line = line.substr(0, line.find("#")); 281 line = line.substr(0, line.find("#"));
272 282
273 if (!line.empty()) { 283 if (!line.empty()) {
274 failure_list->push_back(line); 284 failure_list->push_back(line);
275 } 285 }
276 } 286 }
277 } 287 }
278 288
279 int main(int argc, char *argv[]) { 289 int main(int argc, char *argv[]) {
280 char *program; 290 char *program;
281 google::protobuf::ConformanceTestSuite suite; 291 google::protobuf::ConformanceTestSuite suite;
282 292
293 string failure_list_filename;
283 vector<string> failure_list; 294 vector<string> failure_list;
284 295
285 for (int arg = 1; arg < argc; ++arg) { 296 for (int arg = 1; arg < argc; ++arg) {
286 if (strcmp(argv[arg], "--failure_list") == 0) { 297 if (strcmp(argv[arg], "--failure_list") == 0) {
287 if (++arg == argc) UsageError(); 298 if (++arg == argc) UsageError();
299 failure_list_filename = argv[arg];
288 ParseFailureList(argv[arg], &failure_list); 300 ParseFailureList(argv[arg], &failure_list);
289 } else if (strcmp(argv[arg], "--verbose") == 0) { 301 } else if (strcmp(argv[arg], "--verbose") == 0) {
290 suite.SetVerbose(true); 302 suite.SetVerbose(true);
303 } else if (strcmp(argv[arg], "--enforce_recommended") == 0) {
304 suite.SetEnforceRecommended(true);
291 } else if (argv[arg][0] == '-') { 305 } else if (argv[arg][0] == '-') {
292 fprintf(stderr, "Unknown option: %s\n", argv[arg]); 306 fprintf(stderr, "Unknown option: %s\n", argv[arg]);
293 UsageError(); 307 UsageError();
294 } else { 308 } else {
295 if (arg != argc - 1) { 309 if (arg != argc - 1) {
296 fprintf(stderr, "Too many arguments.\n"); 310 fprintf(stderr, "Too many arguments.\n");
297 UsageError(); 311 UsageError();
298 } 312 }
299 program = argv[arg]; 313 program = argv[arg];
300 } 314 }
301 } 315 }
302 316
303 suite.SetFailureList(failure_list); 317 suite.SetFailureList(failure_list_filename, failure_list);
304 ForkPipeRunner runner(program); 318 ForkPipeRunner runner(program);
305 319
306 std::string output; 320 std::string output;
307 bool ok = suite.RunSuite(&runner, &output); 321 bool ok = suite.RunSuite(&runner, &output);
308 322
309 fwrite(output.c_str(), 1, output.size(), stderr); 323 fwrite(output.c_str(), 1, output.size(), stderr);
310 324
311 return ok ? EXIT_SUCCESS : EXIT_FAILURE; 325 return ok ? EXIT_SUCCESS : EXIT_FAILURE;
312 } 326 }
OLDNEW
« no previous file with comments | « third_party/protobuf/conformance/conformance_test.cc ('k') | third_party/protobuf/conformance/failure_list_cpp.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698