Skip to content

Commit

Permalink
[guess-root] add tests to document the behavior of preexisting commands.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Andre Kuhlenschmidt authored and facebook-github-bot committed Jun 1, 2019
1 parent e9c2e9e commit a05cbb2
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/guess-root/.testconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shell: test.sh
auto_start: false
11 changes: 11 additions & 0 deletions tests/guess-root/config/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[ignore]

[include]

[libs]

[lints]

[options]

[strict]
5 changes: 5 additions & 0 deletions tests/guess-root/config/no-config/d2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

let y = 0;
function f(x = y) {}
function g({x = y}) {}
5 changes: 5 additions & 0 deletions tests/guess-root/d0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

let y = 0;
function f(x = y) {}
function g({x = y}) {}
30 changes: 30 additions & 0 deletions tests/guess-root/guess-root.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
nothing
with file
with file and config
number
no-config/d2.js:3:5,3:5
with bad root directory
number
-:3:5,3:5
with bad root directory, and file
number
no-config/d2.js:3:5,3:5
with bad root directory, and file
number
no-config/d2.js:3:5,3:5
with file batch coverage

Coverage results from 1 file(s):

no-config/d2.js: 88.89% (8 of 9 expressions)

-----------------------------------
Aggregate coverage statistics
-----------------------------------
Files : 1
Expressions :
Covered : 8
Total : 9
Covered Percentage : 88.89%

with bad root directory, and file batch coverage
5 changes: 5 additions & 0 deletions tests/guess-root/no-config/d1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

let y = 0;
function f(x = y) {}
function g({x = y}) {}
25 changes: 25 additions & 0 deletions tests/guess-root/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

echo "nothing"
assert_exit "$EXIT_COULD_NOT_FIND_FLOWCONFIG" "$FLOW" type-at-pos 3 5 < d0.js

echo "with file"
assert_exit "$EXIT_COULD_NOT_FIND_FLOWCONFIG" "$FLOW" type-at-pos no-config/d1.js 3 5

echo "with file and config"
assert_ok "$FLOW" type-at-pos --strip-root config/no-config/d2.js 3 5

echo "with bad root directory"
assert_ok "$FLOW" type-at-pos --root ./config/no-config 3 5 < ./config/no-config/d2.js

echo "with bad root directory, and file"
assert_ok "$FLOW" type-at-pos --strip-root --root ./config/no-config ./config/no-config/d2.js 3 5

echo "with bad root directory, and file"
assert_ok "$FLOW" type-at-pos --strip-root --root ./config/no-config ./config/no-config/d2.js 3 5

echo "with file batch coverage"
assert_ok "$FLOW" batch-coverage --strip-root ./config/no-config/d2.js

echo "with bad root directory, and file batch coverage"
assert_exit "$EXIT_COULD_NOT_FIND_FLOWCONFIG" "$FLOW" batch-coverage --root ./config/no-config ./config/no-config/d2.js

0 comments on commit a05cbb2

Please sign in to comment.