mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e4d0153a67
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33729 This PR addresses [this comment](https://www.internalfb.com/diff/D35820848?dst_version_fbid=496290878846487&transaction_fbid=355967423221044). It makes the CodeGen to the `outputDir` as base directory for the codegen. Finally, it updates the unit tests accordingly. ## Changelog [iOS][Changed] - use `outputDir` as base directory for the codegen and remove the possibility to customize the intermediate path. The generated code requires specific paths in the `#include` directive. Reviewed By: cortinico, dmitryrykun Differential Revision: D35935282 fbshipit-source-id: a9ad4e296efb042cf34b20db5eebb59614beb5f6
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @emails oncall+react_native
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const underTest = require('../generate-artifacts-executor');
|
|
const path = require('path');
|
|
|
|
describe('generateCode', () => {
|
|
it('executeNodes with the right arguents', () => {
|
|
// Define variables and expected values
|
|
const iosOutputDir = 'app/ios/build/generated/ios';
|
|
const library = {config: {name: 'library', type: 'all'}};
|
|
const tmpDir = 'tmp';
|
|
const node = 'usr/bin/node';
|
|
const pathToSchema = 'app/build/schema.json';
|
|
const rnRoot = path.join(__dirname, '../..');
|
|
const libraryType = 'all';
|
|
|
|
const tmpOutDir = path.join(tmpDir, 'out');
|
|
|
|
// mock used functions
|
|
let mkdirSyncInvocationCount = 0;
|
|
jest.mock('fs', () => ({
|
|
mkdirSync: (location, config) => {
|
|
if (mkdirSyncInvocationCount === 0) {
|
|
expect(location).toEqual(tmpOutDir);
|
|
}
|
|
if (mkdirSyncInvocationCount === 1) {
|
|
expect(location).toEqual(iosOutputDir);
|
|
}
|
|
|
|
mkdirSyncInvocationCount += 1;
|
|
},
|
|
}));
|
|
|
|
let execSyncInvocationCount = 0;
|
|
jest.mock('child_process', () => ({
|
|
execSync: command => {
|
|
if (execSyncInvocationCount === 0) {
|
|
const expectedCommand = `${node} ${path.join(
|
|
rnRoot,
|
|
'generate-specs-cli.js',
|
|
)} \
|
|
--platform ios \
|
|
--schemaPath ${pathToSchema} \
|
|
--outputDir ${tmpOutDir} \
|
|
--libraryName ${library.config.name} \
|
|
--libraryType ${libraryType}`;
|
|
expect(command).toEqual(expectedCommand);
|
|
}
|
|
|
|
if (execSyncInvocationCount === 1) {
|
|
expect(command).toEqual(`cp -R ${tmpOutDir}/* ${iosOutputDir}`);
|
|
}
|
|
|
|
execSyncInvocationCount += 1;
|
|
},
|
|
}));
|
|
|
|
underTest._generateCode(iosOutputDir, library, tmpDir, node, pathToSchema);
|
|
expect(mkdirSyncInvocationCount).toBe(2);
|
|
});
|
|
});
|