Don't print "Loaded GHCi configuration" message in ghc -e (#11478)
authorReid Barton <rwbarton@gmail.com>
Fri, 22 Jan 2016 14:59:20 +0000 (09:59 -0500)
committerReid Barton <rwbarton@gmail.com>
Fri, 22 Jan 2016 14:59:23 +0000 (09:59 -0500)
Summary:
Also don't print it if the user specifically requested
non-verbose output with -v0.

Since this means there is no longer any test that checks
for the message, add such a test.

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1817

GHC Trac Issues: #11478

ghc/GHCi/UI.hs
testsuite/tests/ghc-e/should_run/Makefile
testsuite/tests/ghc-e/should_run/T11478.script [new file with mode: 0644]
testsuite/tests/ghc-e/should_run/T11478.stdout [new file with mode: 0644]
testsuite/tests/ghc-e/should_run/all.T
testsuite/tests/ghci/scripts/Makefile
testsuite/tests/ghci/scripts/T10408.stdout
testsuite/tests/ghci/scripts/T11389.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T11389.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T

index 30e70e0..fc03b5f 100644 (file)
@@ -527,7 +527,11 @@ runGHCi paths maybe_exprs = do
              do runInputTWithPrefs defaultPrefs defaultSettings $
                           runCommands $ fileLoop hdl
                 liftIO (hClose hdl `catchIO` \_ -> return ())
-                liftIO $ putStrLn ("Loaded GHCi configuration from " ++ file)
+                -- Don't print a message if this is really ghc -e (#11478).
+                -- Also, let the user silence the message with -v0
+                -- (the default verbosity in GHCi is 1).
+                when (isNothing maybe_exprs && verbosity dflags > 0) $
+                  liftIO $ putStrLn ("Loaded GHCi configuration from " ++ file)
 
   --
 
index 54ce8a3..c98b98a 100644 (file)
@@ -41,3 +41,7 @@ T9905:
 
 T9905b:
        '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e "import qualified Data.List as L" -e "L.sort [2,1]"
+
+# Ensure that ghc -e does not output extra messages about GHCi configuration files
+T11478:
+       '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -ghci-script T11478.script -e 3
diff --git a/testsuite/tests/ghc-e/should_run/T11478.script b/testsuite/tests/ghc-e/should_run/T11478.script
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/tests/ghc-e/should_run/T11478.stdout b/testsuite/tests/ghc-e/should_run/T11478.stdout
new file mode 100644 (file)
index 0000000..00750ed
--- /dev/null
@@ -0,0 +1 @@
+3
index dcb7207..ae28653 100644 (file)
@@ -16,3 +16,4 @@ test('T7299', req_interp, run_command, ['$MAKE --no-print-directory -s T7299'])
 test('T9086', req_interp, run_command, ['$MAKE --no-print-directory -s T9086'])
 test('T9905', req_interp, run_command, ['$MAKE --no-print-directory -s T9905'])
 test('T9905b', req_interp, run_command, ['$MAKE --no-print-directory -s T9905b'])
+test('T11478', req_interp, run_command, ['$MAKE --no-print-directory -s T11478'])
index 017555b..0b70318 100644 (file)
@@ -54,3 +54,10 @@ T10408:
        # and not be ignored when `-ignore-dot-ghci` is specified.
        '$(TEST_HC)' $(TEST_HC_OPTS) --interactive -v0 -ignore-dot-ghci \
            -ghci-script T10408A.script -ghci-script T10408B.script < /dev/null
+
+.PHONY: T11389
+T11389:
+       # Test that "Loaded GHCi configuration" message is printed by default
+       # (without -v0)
+       '$(TEST_HC)' $(TEST_HC_OPTS) --interactive -ignore-dot-ghci \
+            -ghci-script T11389.script < /dev/null | grep 'configuration'
index cef83bc..b13d0a4 100644 (file)
@@ -1,4 +1,2 @@
 "T10408A"
-Loaded GHCi configuration from T10408A.script
 "T10408B"
-Loaded GHCi configuration from T10408B.script
diff --git a/testsuite/tests/ghci/scripts/T11389.script b/testsuite/tests/ghci/scripts/T11389.script
new file mode 100644 (file)
index 0000000..8b8441b
--- /dev/null
@@ -0,0 +1 @@
+"test"
diff --git a/testsuite/tests/ghci/scripts/T11389.stdout b/testsuite/tests/ghci/scripts/T11389.stdout
new file mode 100644 (file)
index 0000000..c92bf91
--- /dev/null
@@ -0,0 +1 @@
+Loaded GHCi configuration from T11389.script
index 17bee5f..d954899 100755 (executable)
@@ -240,3 +240,5 @@ test('T10576b', expect_broken(10576), ghci_script, ['T10576b.script'])
 test('T11051a', normal, ghci_script, ['T11051a.script'])
 test('T11051b', normal, ghci_script, ['T11051b.script'])
 test('T11266', check_stdout(lambda *args: 1), ghci_script, ['T11266.script'])
+
+test('T11389', req_interp, run_command, ['$MAKE -s --no-print-directory T11389'])