Skip to content

Commit c4a9829

Browse files
andrewdacenkometa-codesync[bot]
authored andcommitted
Add LLVM coverage conversion to LCOV format (facebook#55860)
Summary: Pull Request resolved: facebook#55860 Changelog: [Internal] This diff adds the ability to convert LLVM coverage JSON output to LCOV format for C++ code coverage in react-native-fantom. Key additions: - `convertLLVMCoverage.js`: Converts LLVM coverage data (segments, branches, functions) to LCOV format lines - `types.flow.js`: Flow type definitions for LLVM coverage data structures - Test utilities and fixtures for validating the conversion with real coverage data from various C++ files (AppSettings.cpp, Class.h, DevSettingsModule.h, NativeFantom.cpp/h, RawPropsKey.cpp) This enables reporting C++ code coverage from Fantom tests in a standard format that can be consumed by coverage tools. Reviewed By: sammy-SC Differential Revision: D90135000 fbshipit-source-id: 3b22250c4b1665748b6ccb4feb79cc1c20ec7fa6
1 parent 055fb7a commit c4a9829

30 files changed

+47766
-3
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import type {LLVMFileData, LLVMFunctionData} from '../convertLLVMCoverage';
12+
13+
export type LLVMCoverage = {
14+
file: LLVMFileData,
15+
functions: Array<LLVMFunctionData>,
16+
lcov: string[],
17+
};
18+
19+
export default function loadLLVMCoverage(
20+
name:
21+
| 'AppSettings.cpp'
22+
| 'Class.h'
23+
| 'DevSettingsModule.h'
24+
| 'NativeFantom.h'
25+
| 'NativeFantom.cpp'
26+
| 'RawPropsKey.cpp',
27+
): LLVMCoverage {
28+
match (name) {
29+
'AppSettings.cpp' => {
30+
return {
31+
// $FlowExpectedError[untyped-import]
32+
file: require('./resources/AppSettings.cpp.json') as LLVMFileData,
33+
functions:
34+
// $FlowExpectedError[untyped-import]
35+
require('./resources/AppSettings.cpp.functions.json') as Array<LLVMFunctionData>,
36+
// $FlowExpectedError[untyped-import]
37+
lcov: require('./resources/AppSettings.cpp.lcov.json') as string[],
38+
};
39+
}
40+
'Class.h' => {
41+
return {
42+
// $FlowExpectedError[untyped-import]
43+
file: require('./resources/Class.h.json') as LLVMFileData,
44+
functions:
45+
// $FlowExpectedError[untyped-import]
46+
require('./resources/Class.h.functions.json') as Array<LLVMFunctionData>,
47+
// $FlowExpectedError[untyped-import]
48+
lcov: require('./resources/Class.h.lcov.json') as string[],
49+
};
50+
}
51+
'DevSettingsModule.h' => {
52+
return {
53+
// $FlowExpectedError[untyped-import]
54+
file: require('./resources/DevSettingsModule.h.json') as LLVMFileData,
55+
functions:
56+
// $FlowExpectedError[untyped-import]
57+
require('./resources/DevSettingsModule.h.functions.json') as Array<LLVMFunctionData>,
58+
// $FlowExpectedError[untyped-import]
59+
lcov: require('./resources/DevSettingsModule.h.lcov.json') as string[],
60+
};
61+
}
62+
'NativeFantom.cpp' => {
63+
return {
64+
// $FlowExpectedError[untyped-import]
65+
file: require('./resources/NativeFantom.cpp.json') as LLVMFileData,
66+
functions:
67+
// $FlowExpectedError[untyped-import]
68+
require('./resources/NativeFantom.cpp.functions.json') as Array<LLVMFunctionData>,
69+
// $FlowExpectedError[untyped-import]
70+
lcov: require('./resources/NativeFantom.cpp.lcov.json') as string[],
71+
};
72+
}
73+
'NativeFantom.h' => {
74+
return {
75+
// $FlowExpectedError[untyped-import]
76+
file: require('./resources/NativeFantom.h.json') as LLVMFileData,
77+
functions:
78+
// $FlowExpectedError[untyped-import]
79+
require('./resources/NativeFantom.h.functions.json') as Array<LLVMFunctionData>,
80+
// $FlowExpectedError[untyped-import]
81+
lcov: require('./resources/NativeFantom.h.lcov.json') as string[],
82+
};
83+
}
84+
'RawPropsKey.cpp' => {
85+
return {
86+
// $FlowExpectedError[untyped-import]
87+
file: require('./resources/RawPropsKey.cpp.json') as LLVMFileData,
88+
functions:
89+
// $FlowExpectedError[untyped-import]
90+
require('./resources/RawPropsKey.cpp.functions.json') as Array<LLVMFunctionData>,
91+
// $FlowExpectedError[untyped-import]
92+
lcov: require('./resources/RawPropsKey.cpp.lcov.json') as string[],
93+
};
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)