diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2017-01-30 11:53:17 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-01-30 14:00:23 -0500 |
commit | 91691117fc194c525f58ccd5b266dd1d10493e5a (patch) | |
tree | c9fd4334d5bb2441ad4c75a57697cd80462f492e /testsuite/tests/driver | |
parent | 7363d5380e600e2ef868a069d5df6857d9e5c17e (diff) | |
download | haskell-91691117fc194c525f58ccd5b266dd1d10493e5a.tar.gz |
Add a flag to emit error messages as JSON
This patch adds the flag `-ddump-json` which dumps all the compiler
output as a JSON array. This allows tooling to more easily parse GHC's
output to display to users.
The flag is currently experimental and will hopefully be refined for the
next release. In particular I have avoided any changes which involve
significant refactoring and provided what is easy given the current
infrastructure.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: DanielG, gracjan, thomie
Differential Revision: https://phabricator.haskell.org/D3010
GHC Trac Issues: #13190
Diffstat (limited to 'testsuite/tests/driver')
-rw-r--r-- | testsuite/tests/driver/all.T | 2 | ||||
-rw-r--r-- | testsuite/tests/driver/json.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/json.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/driver/json2.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/driver/json2.stderr | 9 |
5 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 17b1206288..e03d4dfdc2 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -261,3 +261,5 @@ test('T12752pass', normal, compile, ['-DSHOULD_PASS=1 -Wcpp-undef']) test('T12955', normal, run_command, ['$MAKE -s --no-print-directory T12955']) test('T12971', ignore_stdout, run_command, ['$MAKE -s --no-print-directory T12971']) +test('json', normal, compile_fail, ['-ddump-json']) +test('json2', normal, compile, ['-ddump-types -ddump-json']) diff --git a/testsuite/tests/driver/json.hs b/testsuite/tests/driver/json.hs new file mode 100644 index 0000000000..1a727fd7cc --- /dev/null +++ b/testsuite/tests/driver/json.hs @@ -0,0 +1,6 @@ +module Foo where + +import Data.List + +id1 :: a -> a +id1 = 5 diff --git a/testsuite/tests/driver/json.stderr b/testsuite/tests/driver/json.stderr new file mode 100644 index 0000000000..ff3915a654 --- /dev/null +++ b/testsuite/tests/driver/json.stderr @@ -0,0 +1,8 @@ + +json.hs:6:7: error: + • No instance for (Num (a -> a)) arising from the literal ‘5’ + (maybe you haven't applied a function to enough arguments?) + • In the expression: 5 + In an equation for ‘id1’: id1 = 5 +[ + {"span": {"file": "json.hs","startLine": 6,"startCol": 7,"endLine": 6,"endCol": 8},"doc": "\u2022 No instance for (Num (a -> a)) arising from the literal \u20185\u2019\n (maybe you haven't applied a function to enough arguments?)\n\u2022 In the expression: 5\n In an equation for \u2018id1\u2019: id1 = 5","severity": "SevError","reason": null}] diff --git a/testsuite/tests/driver/json2.hs b/testsuite/tests/driver/json2.hs new file mode 100644 index 0000000000..0a64a58965 --- /dev/null +++ b/testsuite/tests/driver/json2.hs @@ -0,0 +1,4 @@ +module JSON where + +foo :: a -> a +foo = id diff --git a/testsuite/tests/driver/json2.stderr b/testsuite/tests/driver/json2.stderr new file mode 100644 index 0000000000..33901c68be --- /dev/null +++ b/testsuite/tests/driver/json2.stderr @@ -0,0 +1,9 @@ +TYPE SIGNATURES + foo :: forall a. a -> a +TYPE CONSTRUCTORS +COERCION AXIOMS +Dependent modules: [] +Dependent packages: [base-4.10.0.0, ghc-prim-0.5.0.0, + integer-gmp-1.0.0.1] +[ + {"span": null,"doc": "TYPE SIGNATURES\n foo :: forall a. a -> a\nTYPE CONSTRUCTORS\nCOERCION AXIOMS\nDependent modules: []\nDependent packages: [base-4.10.0.0, ghc-prim-0.5.0.0,\n integer-gmp-1.0.0.1]","severity": "SevOutput","reason": null}] |