diff --git a/tests/guess-root/.testconfig b/tests/guess-root/.testconfig new file mode 100644 index 00000000000..7e0f5b794ef --- /dev/null +++ b/tests/guess-root/.testconfig @@ -0,0 +1,2 @@ +shell: test.sh +auto_start: false diff --git a/tests/guess-root/config/.flowconfig b/tests/guess-root/config/.flowconfig new file mode 100644 index 00000000000..1fed445333e --- /dev/null +++ b/tests/guess-root/config/.flowconfig @@ -0,0 +1,11 @@ +[ignore] + +[include] + +[libs] + +[lints] + +[options] + +[strict] diff --git a/tests/guess-root/config/no-config/d2.js b/tests/guess-root/config/no-config/d2.js new file mode 100644 index 00000000000..9c657602e8c --- /dev/null +++ b/tests/guess-root/config/no-config/d2.js @@ -0,0 +1,5 @@ +// @flow + +let y = 0; +function f(x = y) {} +function g({x = y}) {} diff --git a/tests/guess-root/d0.js b/tests/guess-root/d0.js new file mode 100644 index 00000000000..9c657602e8c --- /dev/null +++ b/tests/guess-root/d0.js @@ -0,0 +1,5 @@ +// @flow + +let y = 0; +function f(x = y) {} +function g({x = y}) {} diff --git a/tests/guess-root/guess-root.exp b/tests/guess-root/guess-root.exp new file mode 100644 index 00000000000..4cba84dcfd8 --- /dev/null +++ b/tests/guess-root/guess-root.exp @@ -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 diff --git a/tests/guess-root/no-config/d1.js b/tests/guess-root/no-config/d1.js new file mode 100644 index 00000000000..9c657602e8c --- /dev/null +++ b/tests/guess-root/no-config/d1.js @@ -0,0 +1,5 @@ +// @flow + +let y = 0; +function f(x = y) {} +function g({x = y}) {} diff --git a/tests/guess-root/test.sh b/tests/guess-root/test.sh new file mode 100644 index 00000000000..5fbf5d033d9 --- /dev/null +++ b/tests/guess-root/test.sh @@ -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