 Chromium Code Reviews
 Chromium Code Reviews Issue 2789433004:
  Add tools for code coverage support in iOS.  (Closed)
    
  
    Issue 2789433004:
  Add tools for code coverage support in iOS.  (Closed) 
  | Index: testing/coverage_util_ios.mm | 
| diff --git a/testing/coverage_util_ios.mm b/testing/coverage_util_ios.mm | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..786ee536894f9bce1f844050948a93ae8fce3dd4 | 
| --- /dev/null | 
| +++ b/testing/coverage_util_ios.mm | 
| @@ -0,0 +1,33 @@ | 
| +// Copyright 2014 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#import <Foundation/Foundation.h> | 
| + | 
| +extern "C" void __llvm_profile_set_filename(const char* name); | 
| + | 
| +namespace coverage_util { | 
| + | 
| +void SetupIfNecessary() { | 
| +#if !defined(NDEBUG)// && defined(ENABLE_TEST_CODE_COVERAGE) | 
| 
lpromero
2017/03/31 11:22:06
I commented the ENABLE_TEST_CODE_COVERAGE variable
 | 
| + static dispatch_once_t onceToken; | 
| 
Eugene But (OOO till 7-30)
2017/03/31 18:27:51
s/onceToken/once_token
Same Style comment for the
 
lpromero
2017/03/31 20:35:20
Since this is now a .mm file, isn't it Objective-C
 
Eugene But (OOO till 7-30)
2017/03/31 20:42:13
C++ Style is used inside C-functions in C++ namesp
 | 
| + dispatch_once(&onceToken, ^{ | 
| + // Writes the profraw file to the Documents directory, where the app has | 
| + // write rights. | 
| + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, | 
| + NSUserDomainMask, YES); | 
| + NSString *documentsDirectory = [paths firstObject]; | 
| + NSString *fileName = | 
| + [documentsDirectory stringByAppendingPathComponent:@"coverage.profraw"]; | 
| + | 
| + // For documentation, see: | 
| + // http://clang.llvm.org/docs/SourceBasedCodeCoverage.html | 
| + __llvm_profile_set_filename([fileName UTF8String]); | 
| 
Eugene But (OOO till 7-30)
2017/03/31 18:27:51
Use sys_string_conversions ?
 
lpromero
2017/03/31 20:35:20
So there is a catch22 :)
base depends on //testing
 | 
| + | 
| + // Print the path for easier retrieval. | 
| + NSLog(@"Coverage data at %@.", fileName); | 
| 
Eugene But (OOO till 7-30)
2017/03/31 18:27:51
Should this be DLOG instead?
 
lpromero
2017/03/31 20:35:20
Idem, I can't use base/logging.h.
 | 
| + }); | 
| +#endif | 
| +} | 
| + | 
| +} // namespace coverage_util |