Skip to content

Commit a05cbb2

Browse files
Andre Kuhlenschmidtfacebook-github-bot
authored andcommitted
[guess-root] add tests to document the behavior of preexisting commands.
Summary: This test documents how some commands use invalid roots as the starting place for searching for a valid root while others just reject the invalid root. It also provides a usage of the type-at-pos command where the optional file argument has been elided. Reviewed By: mvitousek Differential Revision: D15582376 fbshipit-source-id: 5851d038684e35d87f9729da29b38e91af12ed9e
1 parent e9c2e9e commit a05cbb2

File tree

7 files changed

+83
-0
lines changed

7 files changed

+83
-0
lines changed

tests/guess-root/.testconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shell: test.sh
2+
auto_start: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[lints]
8+
9+
[options]
10+
11+
[strict]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @flow
2+
3+
let y = 0;
4+
function f(x = y) {}
5+
function g({x = y}) {}

tests/guess-root/d0.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @flow
2+
3+
let y = 0;
4+
function f(x = y) {}
5+
function g({x = y}) {}

tests/guess-root/guess-root.exp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
nothing
2+
with file
3+
with file and config
4+
number
5+
no-config/d2.js:3:5,3:5
6+
with bad root directory
7+
number
8+
-:3:5,3:5
9+
with bad root directory, and file
10+
number
11+
no-config/d2.js:3:5,3:5
12+
with bad root directory, and file
13+
number
14+
no-config/d2.js:3:5,3:5
15+
with file batch coverage
16+
17+
Coverage results from 1 file(s):
18+
19+
no-config/d2.js: 88.89% (8 of 9 expressions)
20+
21+
-----------------------------------
22+
Aggregate coverage statistics
23+
-----------------------------------
24+
Files : 1
25+
Expressions :
26+
Covered : 8
27+
Total : 9
28+
Covered Percentage : 88.89%
29+
30+
with bad root directory, and file batch coverage

tests/guess-root/no-config/d1.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @flow
2+
3+
let y = 0;
4+
function f(x = y) {}
5+
function g({x = y}) {}

tests/guess-root/test.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo "nothing"
4+
assert_exit "$EXIT_COULD_NOT_FIND_FLOWCONFIG" "$FLOW" type-at-pos 3 5 < d0.js
5+
6+
echo "with file"
7+
assert_exit "$EXIT_COULD_NOT_FIND_FLOWCONFIG" "$FLOW" type-at-pos no-config/d1.js 3 5
8+
9+
echo "with file and config"
10+
assert_ok "$FLOW" type-at-pos --strip-root config/no-config/d2.js 3 5
11+
12+
echo "with bad root directory"
13+
assert_ok "$FLOW" type-at-pos --root ./config/no-config 3 5 < ./config/no-config/d2.js
14+
15+
echo "with bad root directory, and file"
16+
assert_ok "$FLOW" type-at-pos --strip-root --root ./config/no-config ./config/no-config/d2.js 3 5
17+
18+
echo "with bad root directory, and file"
19+
assert_ok "$FLOW" type-at-pos --strip-root --root ./config/no-config ./config/no-config/d2.js 3 5
20+
21+
echo "with file batch coverage"
22+
assert_ok "$FLOW" batch-coverage --strip-root ./config/no-config/d2.js
23+
24+
echo "with bad root directory, and file batch coverage"
25+
assert_exit "$EXIT_COULD_NOT_FIND_FLOWCONFIG" "$FLOW" batch-coverage --root ./config/no-config ./config/no-config/d2.js

0 commit comments

Comments
 (0)