-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: To ensure greater type safety, we want to generate some cpp tests for the fromRawValue conversions This diff adds support to generate Tests.cpp along with the `buck test` targets itegrated into the rn_codegen rule automatically. The tests just `assert(true, true)` as a starting point Reviewed By: fkgozali Differential Revision: D14739493 fbshipit-source-id: fc9dea64ea31e6af7d997aebc54cfd459d48bf4f
- Loading branch information
1 parent
44fe990
commit bddd9c7
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/react-native-codegen/src/generators/GenerateTests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {SchemaType} from '../CodegenSchema'; | ||
|
||
// File path -> contents | ||
type FilesOutput = Map<string, string>; | ||
|
||
const template = ` | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
#include <gtest/gtest.h> | ||
TEST(::_COMPONENT_NAME_::, etc) { | ||
ASSERT_EQ(true, true); | ||
} | ||
`; | ||
|
||
module.exports = { | ||
generate(libraryName: string, schema: SchemaType): FilesOutput { | ||
const fileName = 'Tests.cpp'; | ||
|
||
const replacedTemplate = template | ||
.replace('::_COMPONENT_NAME_::', libraryName) | ||
.trim(); | ||
return new Map([[fileName, replacedTemplate]]); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters