mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add environment variables to print Fantom output and buck commands (#48440)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48440 Changelog: [internal] Modifies the Fantom runner to read 2 new environment variables to help with debugging: - `FANTOM_PRINT_OUTPUT`: prints the output of the CLI to the output of the test. - `FANTOM_LOG_COMMANDS`: logs the buck commands executed by the runner, so they can be re-run outside the runner for debugging, etc. Reviewed By: rshest Differential Revision: D67682750 fbshipit-source-id: aff48c4f47078db1be53e0ee105089fbc921768f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
42b911b5cb
commit
d28300ad9d
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
export const printCLIOutput: boolean = Boolean(process.env.FANTOM_PRINT_OUTPUT);
|
||||
|
||||
export const logCommands: boolean = Boolean(process.env.FANTOM_LOG_COMMANDS);
|
||||
+3
-4
@@ -13,6 +13,7 @@ import type {TestSuiteResult} from '../runtime/setup';
|
||||
import type {AsyncCommandResult} from './utils';
|
||||
|
||||
import entrypointTemplate from './entrypoint-template';
|
||||
import * as EnvironmentOptions from './EnvironmentOptions';
|
||||
import getFantomTestConfig from './getFantomTestConfig';
|
||||
import {FantomTestConfigMode} from './getFantomTestConfig';
|
||||
import {
|
||||
@@ -43,8 +44,6 @@ const BUILD_OUTPUT_PATH = fs.mkdtempSync(
|
||||
path.join(BUILD_OUTPUT_ROOT, `run-${Date.now()}-`),
|
||||
);
|
||||
|
||||
const PRINT_FANTOM_OUTPUT: false = false;
|
||||
|
||||
async function processRNTesterCommandResult(
|
||||
result: AsyncCommandResult,
|
||||
): Promise<TestSuiteResult> {
|
||||
@@ -108,7 +107,7 @@ async function processRNTesterCommandResult(
|
||||
throw new Error(getDebugInfoFromCommandResult(getResultWithOutput()));
|
||||
}
|
||||
|
||||
if (PRINT_FANTOM_OUTPUT) {
|
||||
if (EnvironmentOptions.printCLIOutput) {
|
||||
console.log(getDebugInfoFromCommandResult(getResultWithOutput()));
|
||||
}
|
||||
|
||||
@@ -248,7 +247,7 @@ module.exports = async function runTest(
|
||||
'--featureFlags',
|
||||
JSON.stringify(testConfig.flags.common),
|
||||
'--minLogLevel',
|
||||
PRINT_FANTOM_OUTPUT ? 'info' : 'error',
|
||||
EnvironmentOptions.printCLIOutput ? 'info' : 'error',
|
||||
]);
|
||||
|
||||
const processedResult = await processRNTesterCommandResult(
|
||||
|
||||
+11
@@ -9,6 +9,7 @@
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
import * as EnvironmentOptions from './EnvironmentOptions';
|
||||
import {spawn, spawnSync} from 'child_process';
|
||||
import crypto from 'crypto';
|
||||
import fs from 'fs';
|
||||
@@ -66,10 +67,18 @@ export type SyncCommandResult = {
|
||||
stderr: string,
|
||||
};
|
||||
|
||||
function maybeLogCommand(command: string, args: Array<string>): void {
|
||||
if (EnvironmentOptions.logCommands) {
|
||||
console.log(`RUNNING \`${command} ${args.join(' ')}\``);
|
||||
}
|
||||
}
|
||||
|
||||
export function runCommand(
|
||||
command: string,
|
||||
args: Array<string>,
|
||||
): AsyncCommandResult {
|
||||
maybeLogCommand(command, args);
|
||||
|
||||
const childProcess = spawn(command, args, {
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
@@ -107,6 +116,8 @@ export function runCommandSync(
|
||||
command: string,
|
||||
args: Array<string>,
|
||||
): SyncCommandResult {
|
||||
maybeLogCommand(command, args);
|
||||
|
||||
const result = spawnSync(command, args, {
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
|
||||
Reference in New Issue
Block a user