Export default module name 'Main' from within TestMain.hs file (#512)

Summary:
**Summary**

**Current**
`stack test` fails with an error "output was redirected with -o, but no output will be generated
because there is no Main module"

**Expected**
`stack test` should run tests to completion

The cause here seems to be that the [`main-is` flag](a88e0669f7/duckling.cabal (L851)) supplies the *filename* in which to begin tests, but expects to find a *module* named `Main` there by default.

Two possible fixes are possible - either:

- [Add a ghc-options flag](https://github.com/facebook/duckling/issues/505#issue-650474748) to specify a module name; confusingly the flag name is also `main-is`
- Use the default `Main` module name within TestMain.hs

(the approach taken here is the latter, since this avoids duplicating use of flags named `main-is` in slightly different contexts)

**References**
- https://github.com/facebook/duckling/issues/505
- https://github.com/haskell/cabal/issues/4315

**Version Info**
```sh
$ stack --version
1.9.3.1 x86_64
Compiled with:
- Cabal-2.4.0.1
# <remainder of output omitted>
```

Resolves https://github.com/facebook/duckling/issues/505

Pull Request resolved: https://github.com/facebook/duckling/pull/512

Reviewed By: girifb

Differential Revision: D22799888

Pulled By: patapizza

fbshipit-source-id: 2c0808790e6671e6bc3c9b1f322e57b8dc32a8cc
This commit is contained in:
James Addison 2020-07-30 11:17:16 -07:00 committed by Facebook GitHub Bot
parent a88e0669f7
commit 5e8277e105

16
github/tests/TestMain.hs Normal file
View File

@ -0,0 +1,16 @@
-- Copyright (c) 2016-present, Facebook, Inc.
-- All rights reserved.
--
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree.
module Main where
import Data.String
import Test.Tasty
import Duckling.Tests
import Prelude
main :: IO ()
main = defaultMain tests