fix[devtools/ci]: fixed incorrect condition calculation for @reactVersion annotation (#26997)
Suppose that you have this setup for devtools test: ``` // @reactVersion <= 18.1 // @reactVersion >= 17.1 ``` With previous implementation, the accumulated condition will be `"<= 18.1" && ">= 17.1"`, which is just `">= 17.1"`, when evaluated. That's why we executed some tests for old versions of react on main (and failed). With these changes the resulting condition will be `"<= 18.1 >= 17.1"`, not using `&&`, because semver does not support this operator. All currently failing tests will be skipped now as expected. Also increased timeout value for shell server to start
Ruslan Lesiutin committed
Jun 23, 2023 at 16:45 UTC
8ec962d825fc948ffda5ab863e639cd4158935ba
3 files changed
+21
-23
packages/react-devtools-extensions/src/__tests__/xGoogleIgnoreList-test.js
+1
-1
@@ -13,7 +13,7 @@ import path from 'path';
13
import {rimrafSync} from 'rimraf';
14
15
describe('x_google_ignoreList source map extension', () => {
16
- jest.setTimeout(30 * 1000);
16
+ jest.setTimeout(60 * 1000);
17
18
const pathToExtensionsPackage = path.resolve(__dirname, '..', '..');
19
const pathToChromeExtensionBuild = path.join(
scripts/babel/transform-react-version-pragma.js
+19
-21
@@ -26,31 +26,29 @@ function transform(babel) {
26
return null;
27
}
28
29
- let conditions = null;
30
- for (const line of comments) {
31
- const commentStr = line.value.trim();
32
- if (commentStr.startsWith(GATE_VERSION_STR)) {
33
- const condition = t.stringLiteral(
34
- commentStr.slice(GATE_VERSION_STR.length)
35
- );
36
- if (conditions === null) {
37
- conditions = [condition];
38
- } else {
39
- conditions.push(condition);
29
+ const resultingCondition = comments.reduce(
30
+ (accumulatedCondition, commentLine) => {
31
+ const commentStr = commentLine.value.trim();
32
+
33
+ if (!commentStr.startsWith(GATE_VERSION_STR)) {
34
+ return accumulatedCondition;
35
+ }
36
+
37
+ const condition = commentStr.slice(GATE_VERSION_STR.length);
38
+ if (accumulatedCondition === null) {
39
+ return condition;
40
}
41
- }
42
- }
41
44
- if (conditions !== null) {
45
- let condition = conditions[0];
46
- for (let i = 1; i < conditions.length; i++) {
47
- const right = conditions[i];
48
- condition = t.logicalExpression('&&', condition, right);
49
- }
50
- return condition;
51
- } else {
42
+ return accumulatedCondition.concat(' ', condition);
43
+ },
44
+ null
45
+ );
46
+
47
+ if (resultingCondition === null) {
48
return null;
49
}
50
+
51
+ return t.stringLiteral(resultingCondition);
52
}
53
54
return {
scripts/circleci/run_devtools_e2e_tests.js
+1
-1
@@ -76,7 +76,7 @@ function runTestShell() {
76
// Assume the test shell server failed to start.
77
logError('Testing shell server failed to start');
78
exitWithCode(1);
79
- }, 30000);
79
+ }, 60 * 1000);
80
81
logBright('Starting testing shell server');
82