react-native/RNTester/RNTesterUnitTests
Ramanpreet Nara f37093319b Start using getConstants
Summary:
TurboModules depend on a getConstants method. Existing ObjectiveC modules do not have this method. Therefore, I moved the contents of `constantsToExport` to `getConstants` and then had `constantsToExports` call `getConstants`.

facebook
Since all NativeModules will eventually need to be migrated to the TurboModule system, I didn't restrict this to just the NativeModules in Marketplace.

```
const fs = require('fs');

if (process.argv.length < 3) {
    throw new Error('Expected a file containing a list of native modules as the third param');
}

function read(filename) {
    return fs.readFileSync(filename, 'utf8');
}

const nativeModuleFilenames = read(process.argv[2]).split('\n').filter(Boolean);

nativeModuleFilenames.forEach((fileName) => {
    if (fileName.endsWith('.h')) {
        return;
    }

    const absPath = `${process.env.HOME}/${fileName}`;
    const fileSource = read(absPath);

    if (/(\n|^)-\s*\((.+)\)getConstants/.test(fileSource)) {
        return;
    }

    const constantsToExportRegex = /(\n|^)-\s*\((.+)\)constantsToExport/;
    const result = constantsToExportRegex.exec(fileSource);

    if (result == null) {
        throw new Error(`Didn't find a constantsToExport function inside NativeModule ${fileName}`);
    }

    const returnType = result[2];

    const newFileSource = fileSource.replace(
        constantsToExportRegex,
        '$1- ($2)constantsToExport\n' +
        '{\n' +
        `  return ${returnType.includes('ModuleConstants') ? '($2)' : ''}[self getConstants];\n` +
        '}\n' +
        '\n' +
        '- ($2)getConstants'
    );

    fs.writeFileSync(absPath, newFileSource);
});
```

```
> xbgs -l ')constantsToExport'
```

Reviewed By: fkgozali

Differential Revision: D13951197

fbshipit-source-id: 394a319d42aff466c56a3d748e17c335307a8f47
2019-02-04 17:46:56 -08:00
..
OCMock Re-license and rename UIExplorer integration test app as RNTester 2017-05-08 11:31:19 -07:00
Info.plist Re-license and rename UIExplorer integration test app as RNTester 2017-05-08 11:31:19 -07:00
RCTAllocationTests.m Remove unused code using JSC 2018-10-18 01:06:25 -07:00
RCTAnimationUtilsTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBlobManagerTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBundleURLProviderTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTComponentPropsTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTConvert_NSURLTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTConvert_YGValueTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTDevMenuTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTEventDispatcherTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTFontTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTFormatErrorTests.m Update RCTFormatError to support segment ids 2018-12-18 16:23:39 -08:00
RCTGzipTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTImageLoaderHelpers.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTImageLoaderHelpers.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTImageLoaderTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTImageUtilTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTJSONTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTMethodArgumentTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModuleInitNotificationRaceTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModuleInitTests.m Start using getConstants 2019-02-04 17:46:56 -08:00
RCTModuleMethodTests.mm Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTMultipartStreamReaderTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTNativeAnimatedNodesManagerTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTShadowViewTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTUIManagerTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTURLUtilsTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTUnicodeDecodeTests.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RNTesterUnitTestsBundle.js Fix linting issues (#22062) 2018-11-01 14:29:16 -07:00
libOCMock.a Re-license and rename UIExplorer integration test app as RNTester 2017-05-08 11:31:19 -07:00