Skip to content

Commit

Permalink
Emit a warning when -g was not passed (#268)
Browse files Browse the repository at this point in the history
Fixes #268.
  • Loading branch information
sgraf812 committed Sep 13, 2024
1 parent 51cb522 commit e32103f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/Main.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Path settings auto-generated by Cabal:
> import Happy.Tabular.Info (genInfoFile)

> import System.Console.GetOpt
> import Control.Monad ( liftM, when )
> import Control.Monad ( liftM, when, unless )
> import System.Environment
> import System.Exit (exitWith, ExitCode(..))
> import Data.Char
Expand Down Expand Up @@ -62,6 +62,11 @@ Read and parse the CLI arguments.
> where
> runParserGen cli fl_name = do

If no -g flag has been passed, show a warning.

> unless (OptGhcTarget `elem` cli) $
> hPutStrLn stderr "Warning: With happy 2.0, the --ghc flag has become non-optional. To suppress this warning, pass the --ghc flag."

Open the file.

> fl <- readFile fl_name
Expand Down
8 changes: 4 additions & 4 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ ERROR_TESTS = error001.y

# NOTE: `cabal` will set the `happy_datadir` env-var accordingly before invoking the test-suite
#TEST_HAPPY_OPTS = --strict --template=..
TEST_HAPPY_OPTS = --strict
TEST_HAPPY_OPTS = --strict -g

%.n.hs : %.y
$(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@

%.n.hs : %.ly
$(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@
$(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@

%.c.hs : %.y
$(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@
$(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@

%.c.hs : %.ly
$(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@
Expand All @@ -80,7 +80,7 @@ path.run : # simply a test to output the path of the built happy executable, use

check.%.y : %.y
@echo "--> Checking $<..."
$(HAPPY) $(TEST_HAPPY_OPTS) $< 1>$*.run.stdout 2>$*.run.stderr || true
$(HAPPY) $(TEST_HAPPY_OPTS) -g $< 1>$*.run.stdout 2>$*.run.stderr || true
sed -i '/^Up to date$$/d' $*.run.stdout $*.run.stderr
@diff -u --ignore-all-space $*.stdout $*.run.stdout
@diff -u --ignore-all-space $*.stderr $*.run.stderr
Expand Down

0 comments on commit e32103f

Please sign in to comment.