Skip to content

Commit b3f8c21

Browse files
SamChou19815facebook-github-bot
authored andcommitted
[flow][tests] Consistent no-flowlib behavior for tests
Summary: Currently for saved state tests, we have an inconsistent `no-flowlib` setup. During the initial state saving, we run it with the default on `--no-flowlib`, but when running the test script, we don't pass the flag (because there was no way to pass it by environement variables). It caused an inconsistency between saved-state and the real state. Until now, it just happens to work, because we strip most of the libdef stuff from saved-state. But it will break in the next diff when we will add libdef stuff into saved state. This diff adds env-var support for `--no-flowlib`, so that the entire test suite with saved state can run in a consistent environment. Changelog: [internal] Reviewed By: panagosg7 Differential Revision: D69599623 fbshipit-source-id: e07b7ffe1f5955572ab529abc00de5d21b125b0a
1 parent 91754a1 commit b3f8c21

File tree

8 files changed

+21
-10
lines changed

8 files changed

+21
-10
lines changed

scripts/run-one-test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ runtest() {
537537
(
538538
set -e # The script should probably use this option
539539
export PATH="$THIS_DIR/scripts/tests_bin:$PATH"
540+
if [ "$flowlib" == " --no-flowlib" ]; then
541+
export NO_FLOWLIB=1
542+
fi
540543
source "$shell" "$FLOW"
541544
) 1> "$abs_out_file" 2> "$stderr_dest"
542545
code=$?

src/commands/commandUtils.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ let options_flags =
10231023
(optional bool)
10241024
~doc:
10251025
"If true, always wait for rechecks to finish before serving commands (default: false)"
1026-
|> flag "--no-flowlib" truthy ~doc:"Do not include embedded declarations"
1026+
|> flag "--no-flowlib" truthy ~doc:"Do not include embedded declarations" ~env:"NO_FLOWLIB"
10271027
|> flag
10281028
"--munge-underscore-members"
10291029
truthy

tests/libdef_outside_of_root/libdef_outside_of_root.exp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@ References:
1212
^^^ [2]
1313

1414

15+
Error ------------------------------------------------------------------------------------------- root/use-react.js:1:19
1516

16-
Found 1 error
17+
Cannot resolve module `react`. [cannot-resolve-module]
18+
19+
1| import React from 'react';
20+
^^^^^^^
21+
22+
23+
24+
Found 2 errors

tests/libdef_parse_error_lazy_mode/libdef_parse_error_lazy_mode.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Unexpected token `;`, expected an identifier
99

1010
Found 1 error
1111

12-
The Flow server is currently in lazy mode and is only checking 0/12 files.
12+
The Flow server is currently in lazy mode and is only checking 0/1 files.
1313
To learn more, visit flow.org/en/docs/lang/lazy-modes

tests/saved_state_reinit_upstream_change_git/saved_state_reinit_upstream_change_git.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Found correct merge base hash: Yes
1515
No new errors:
1616
No errors!
1717

18-
The Flow server is currently in lazy mode and is only checking 14/15 files.
18+
The Flow server is currently in lazy mode and is only checking 3/4 files.
1919
To learn more, visit flow.org/en/docs/lang/lazy-modes
2020

2121
Moving to commit 2
2222

2323
No new errors:
2424
No errors!
2525

26-
The Flow server is currently in lazy mode and is only checking 0/15 files.
26+
The Flow server is currently in lazy mode and is only checking 0/4 files.
2727
To learn more, visit flow.org/en/docs/lang/lazy-modes
2828

2929
Found correct merge base hash: Yes
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
No errors!
22

3-
The Flow server is currently in lazy mode and is only checking 13/13 files.
3+
The Flow server is currently in lazy mode and is only checking 2/2 files.
44
To learn more, visit flow.org/en/docs/lang/lazy-modes
55
No errors!
66

7-
The Flow server is currently in lazy mode and is only checking 1/14 files.
7+
The Flow server is currently in lazy mode and is only checking 1/3 files.
88
To learn more, visit flow.org/en/docs/lang/lazy-modes

tests/saved_state_update_parse_error/saved_state_update_parse_error.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Unexpected identifier, expected the token `)`
1111

1212
Found 1 error
1313

14-
The Flow server is currently in lazy mode and is only checking 13/13 files.
14+
The Flow server is currently in lazy mode and is only checking 2/2 files.
1515
To learn more, visit flow.org/en/docs/lang/lazy-modes
1616

1717
Parse error, but no typing error in b.js:
@@ -27,5 +27,5 @@ Unexpected identifier, expected the token `)`
2727

2828
Found 1 error
2929

30-
The Flow server is currently in lazy mode and is only checking 13/13 files.
30+
The Flow server is currently in lazy mode and is only checking 2/2 files.
3131
To learn more, visit flow.org/en/docs/lang/lazy-modes
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
No errors!
22

3-
The Flow server is currently in lazy mode and is only checking 14/14 files.
3+
The Flow server is currently in lazy mode and is only checking 3/3 files.
44
To learn more, visit flow.org/en/docs/lang/lazy-modes

0 commit comments

Comments
 (0)