Skip to content

Commit

Permalink
[flow][tests] Consistent no-flowlib behavior for tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Feb 13, 2025
1 parent 91754a1 commit b3f8c21
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions scripts/run-one-test
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ runtest() {
(
set -e # The script should probably use this option
export PATH="$THIS_DIR/scripts/tests_bin:$PATH"
if [ "$flowlib" == " --no-flowlib" ]; then
export NO_FLOWLIB=1
fi
source "$shell" "$FLOW"
) 1> "$abs_out_file" 2> "$stderr_dest"
code=$?
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ let options_flags =
(optional bool)
~doc:
"If true, always wait for rechecks to finish before serving commands (default: false)"
|> flag "--no-flowlib" truthy ~doc:"Do not include embedded declarations"
|> flag "--no-flowlib" truthy ~doc:"Do not include embedded declarations" ~env:"NO_FLOWLIB"
|> flag
"--munge-underscore-members"
truthy
Expand Down
10 changes: 9 additions & 1 deletion tests/libdef_outside_of_root/libdef_outside_of_root.exp
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ References:
^^^ [2]


Error ------------------------------------------------------------------------------------------- root/use-react.js:1:19

Found 1 error
Cannot resolve module `react`. [cannot-resolve-module]

1| import React from 'react';
^^^^^^^



Found 2 errors
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Unexpected token `;`, expected an identifier

Found 1 error

The Flow server is currently in lazy mode and is only checking 0/12 files.
The Flow server is currently in lazy mode and is only checking 0/1 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Found correct merge base hash: Yes
No new errors:
No errors!

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

Moving to commit 2

No new errors:
No errors!

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

Found correct merge base hash: Yes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
No errors!

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

The Flow server is currently in lazy mode and is only checking 1/14 files.
The Flow server is currently in lazy mode and is only checking 1/3 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Unexpected identifier, expected the token `)`

Found 1 error

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

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

Found 1 error

The Flow server is currently in lazy mode and is only checking 13/13 files.
The Flow server is currently in lazy mode and is only checking 2/2 files.
To learn more, visit flow.org/en/docs/lang/lazy-modes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
No errors!

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

0 comments on commit b3f8c21

Please sign in to comment.