Skip to content

Commit

Permalink
Merge pull request #112 from SamirTalwar/upgrade-everything
Browse files Browse the repository at this point in the history
Upgrade GHC to v9.6, and nixpkgs for good measure.
  • Loading branch information
SamirTalwar authored Sep 24, 2024
2 parents dd1bf1c + 9bb6c4e commit c2424c6
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 105 deletions.
5 changes: 5 additions & 0 deletions fixtures/calculator/smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ tests:
fixtures/calculator.rb:4:in `<main>': undefined method `to-the-power-of' for 3:Fixnum (NoMethodError)
- |
fixtures/calculator.rb:4:in `<main>': undefined method `to-the-power-of' for 3:Integer (NoMethodError)
- |
fixtures/calculator.rb:4:in `<main>': undefined method `to-the-power-of' for an instance of Integer (NoMethodError)
puts tokens[0].to_i.send(tokens[1].to_sym, tokens[2].to_i)
^^^^^
- name: ignored-test
ignored: true
Expand Down
56 changes: 28 additions & 28 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 8 additions & 36 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,23 @@
description = "Smoke";

inputs = {
flake-compat.url = github:edolstra/flake-compat;
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-utils.url = github:numtide/flake-utils;
nixpkgs.url = github:NixOS/nixpkgs/master;
haskellTar.url = github:haskell/tar/dbf8c995153c8a80450724d9f94cf33403740c80;
haskellTar.flake = false;
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
{ self
, flake-compat
, flake-utils
, nixpkgs
, haskellTar
}:
flake-utils.lib.eachDefaultSystem (system:
let
ghcVersion = lib.strings.fileContents ./ghc.version;
ghcName = "ghc" + lib.strings.stringAsChars (c: if c == "." then "" else c) ghcVersion;
pkgs = import nixpkgs {
inherit system;
overlays = [
(self: super: {
haskell = super.haskell // {
packages = super.haskell.packages // {
# haskell package set from the version of GHC specified by `./ghc.version`
${ghcName} = super.haskell.packages.${ghcName}.override {
overrides = hself: hsuper: {
# Override tar with the patched version; see stack.yaml for details.
# The tests don't work.
tar = hsuper.callCabal2nixWithOptions "tar" haskellTar "--no-check" { };
} // (if super.stdenv.targetPlatform.isDarwin
then
# macOS-specific overrides:
{
# On aarch64-darwin, this creates a cycle.
# see https://github.com/NixOS/nixpkgs/issues/140774
ormolu = super.haskell.lib.overrideCabal hsuper.ormolu (drv: { enableSeparateBinOutput = false; });
}
else
# We don't need to override anything on Linux:
{ });
};
};
};
})
];
};
pkgs = import nixpkgs { inherit system; };

inherit (pkgs) lib haskell;
inherit (haskell.lib) overrideCabal justStaticExecutables doStrip;
Expand All @@ -66,7 +35,10 @@

smoke =
let
drv = hsPkgs.callCabal2nix "smoke" (pkgs.nix-gitignore.gitignoreSource [ ] ./.) { };
drv = hsPkgs.callCabal2nix "smoke" (pkgs.nix-gitignore.gitignoreSource [ ] ./.) {
# Override tar with the patched version; see stack.yaml for details.
tar = hsPkgs.tar_0_6_3_0;
};
in
haskell.lib.addExtraLibraries drv staticLibs;
in
Expand Down
2 changes: 1 addition & 1 deletion ghc.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.2.6
9.6.6
8 changes: 4 additions & 4 deletions src/app/Test/Smoke/App/PrintResults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ printFailingInput value =
putRed $ fromString $ indentedKey (" " ++ unFixtureName (fixtureName @a) ++ ":")
putPlainLn $ indented outputIndentation (serializeFixture v)

printFailingOutput :: forall a. FromFixture a => AssertionResult a -> Output ()
printFailingOutput :: forall a. (FromFixture a) => AssertionResult a -> Output ()
printFailingOutput = printFailures (ShortName (unFixtureName (fixtureName @a)))

printFailingFilesOutput ::
Expand All @@ -58,10 +58,10 @@ printFailingFilesOutput fileResults =
putRedLn " files:"
forM_ (Map.assocs fileResults) $ uncurry printFailingFileOutput

printFailingFileOutput :: FromFixture a => Path Relative File -> AssertionResult a -> Output ()
printFailingFileOutput :: (FromFixture a) => Path Relative File -> AssertionResult a -> Output ()
printFailingFileOutput path = printFailures (LongName (" " ++ toFilePath path))

printFailures :: FromFixture a => PartName -> AssertionResult a -> Output ()
printFailures :: (FromFixture a) => PartName -> AssertionResult a -> Output ()
printFailures _ AssertionSuccess =
pure ()
printFailures name (AssertionFailure (SingleAssertionFailure failure)) = do
Expand Down Expand Up @@ -92,7 +92,7 @@ failureIsInline AssertionFailureContains {} = False
failureIsInline AssertionFailureExpectedFileError {} = True
failureIsInline AssertionFailureActualFileError {} = True

printFailure :: FromFixture a => AssertionFailure a -> Output ()
printFailure :: (FromFixture a) => AssertionFailure a -> Output ()
printFailure (AssertionFailureDiff (Expected expected) (Actual actual)) =
printDiff (serializeFixture expected) (serializeFixture actual)
printFailure (AssertionFailureContains (Expected expected) (Actual actual)) = do
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ processOutputs location (TestPlan _ _ fallbackShell _ _ _ _ expectedStatus expec
expectedFiles
pure $ FinishedTest statusResult stdOutResult stdErrResult fileResults
where
assertEqual :: Eq a => a -> a -> EqualityResult a
assertEqual :: (Eq a) => a -> a -> EqualityResult a
assertEqual expected actual
| expected == actual = EqualitySuccess
| otherwise = EqualityFailure (Expected expected) (Actual actual)
Expand Down Expand Up @@ -77,5 +77,5 @@ ifEmpty x xs
| Vector.null xs = Vector.singleton x
| otherwise = xs

defaultIfEmpty :: Default a => Vector a -> Vector a
defaultIfEmpty :: (Default a) => Vector a -> Vector a
defaultIfEmpty = ifEmpty def
6 changes: 3 additions & 3 deletions src/lib/Test/Smoke/Bless.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ blessFinishedTest location testPlan@(TestPlan {planTest = test}) result@(Finishe
writeToPath (location </> path) text
pure $ makeAfter AssertionSuccess before

serialize :: forall a. FromFixture a => Vector (TestOutput a) -> AssertionResult a -> IO (Maybe (Path Relative File, Text))
serialize :: forall a. (FromFixture a) => Vector (TestOutput a) -> AssertionResult a -> IO (Maybe (Path Relative File, Text))
serialize _ AssertionSuccess =
pure Nothing
serialize outputs (AssertionFailure result) =
Expand All @@ -61,7 +61,7 @@ serialize outputs (AssertionFailure result) =
_ ->
throwIO $ CouldNotBlessWithMultipleValues (fixtureName @a)

serializeFailure :: forall a. FromFixture a => TestOutput a -> AssertionFailures a -> IO (Maybe (Path Relative File, Text))
serializeFailure :: forall a. (FromFixture a) => TestOutput a -> AssertionFailures a -> IO (Maybe (Path Relative File, Text))
serializeFailure (TestOutputFromFile _ path) (SingleAssertionFailure (AssertionFailureDiff _ (Actual actual))) =
pure $ Just (path, serializeFixture actual)
serializeFailure _ (SingleAssertionFailure (AssertionFailureDiff _ (Actual actual))) =
Expand All @@ -77,5 +77,5 @@ serializeFailure _ (SingleAssertionFailure (AssertionFailureActualFileError _))
serializeFailure _ (MultipleAssertionFailures _) =
throwIO $ CouldNotBlessWithMultipleValues (fixtureName @a)

failed :: Applicative f => Test -> SmokeBlessError -> f TestResult
failed :: (Applicative f) => Test -> SmokeBlessError -> f TestResult
failed test = pure . TestErrored test . BlessError
8 changes: 4 additions & 4 deletions src/lib/Test/Smoke/Discovery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Control.Monad (forM, unless)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Except (ExceptT (..), except, throwE, withExceptT)
import Data.Aeson qualified as Aeson
import Data.Aeson.Internal qualified as Aeson.Internal
import Data.Aeson.Types qualified as Aeson.Types
import Data.List qualified as List
import Data.Text qualified as Text
import Data.Vector (Vector)
Expand Down Expand Up @@ -75,9 +75,9 @@ decodeSpecificationFile path = withExceptT (InvalidSpecification path) $ do
withExceptT Yaml.prettyPrintParseException $
ExceptT $
Yaml.decodeFileEither (toFilePath resolvedPath)
except $ case Aeson.Internal.ifromJSON value of
Aeson.Internal.IError jsonPath message -> Left $ Aeson.Internal.formatError jsonPath message
Aeson.Internal.ISuccess suite -> Right suite
except $ case Aeson.Types.ifromJSON value of
Aeson.Types.IError jsonPath message -> Left $ Aeson.Types.formatError jsonPath message
Aeson.Types.ISuccess suite -> Right suite

parseRoot :: String -> Discovery Root
parseRoot location = do
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
runExceptTIO :: (Exception e, MonadIO m) => ExceptT e m a -> m a
runExceptTIO = either (liftIO . throwIO) pure <=< runExceptT

onNothingThrow :: Monad m => e -> Maybe a -> ExceptT e m a
onNothingThrow :: (Monad m) => e -> Maybe a -> ExceptT e m a
onNothingThrow exception = maybe (throwE exception) pure

onNothingThrow_ :: Monad m => e -> Maybe a -> ExceptT e m ()
onNothingThrow_ :: (Monad m) => e -> Maybe a -> ExceptT e m ()
onNothingThrow_ exception = (>> pure ()) . onNothingThrow exception

handleError :: (a -> b) -> Either a b -> b
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Test/Smoke/Plan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ readTestOutput _ (TestOutputInline assertion) =
readTestOutput location (TestOutputFromFile constructor contents) =
liftIO $ either AssertFileError constructor <$> runExceptT (readPath location contents)

readPath :: ToFixture a => Path Resolved Dir -> Path Relative File -> ExceptT SmokeFileError IO a
readPath :: (ToFixture a) => Path Resolved Dir -> Path Relative File -> ExceptT SmokeFileError IO a
readPath location path =
deserializeFixture
<$> withExceptT
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Types/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Test.Smoke.Types.Errors
import Test.Smoke.Types.Filters

data Assert a where
AssertEquals :: Eq a => a -> Assert a
AssertContains :: FromFixture a => Text -> Assert a
AssertEquals :: (Eq a) => a -> Assert a
AssertContains :: (FromFixture a) => Text -> Assert a
AssertFiltered :: (FromFixture a, ToFixture a) => Filter -> Assert a -> Assert a
AssertFileError :: SmokeFileError -> Assert a

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Test/Smoke/Types/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FromFixture a where
fixtureName :: FixtureName
serializeFixture :: a -> Text

parseFixtureJSON :: ToFixture a => String -> Value -> Parser a
parseFixtureJSON :: (ToFixture a) => String -> Value -> Parser a
parseFixtureJSON name = withText name (return . deserializeFixture)

instance ToFixture Text where
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Types/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ instance FromJSON TestFile where

newtype Many a = Many {unMany :: Vector a}

instance FromJSON a => FromJSON (Many a) where
instance (FromJSON a) => FromJSON (Many a) where
parseJSON a@(Array _) = Many <$> parseJSON a
parseJSON v = Many . Vector.singleton <$> parseJSON v

manyMaybe :: FromJSON a => Maybe (Many a) -> Vector a
manyMaybe :: (FromJSON a) => Maybe (Many a) -> Vector a
manyMaybe Nothing = Vector.empty
manyMaybe (Just v) = unMany v
6 changes: 3 additions & 3 deletions src/lib/Test/Smoke/Types/Values.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data TestInput a where
TestInputFromFile :: Path Relative File -> TestInput a
TestInputFiltered :: TestInput a -> Filter -> TestInput a

instance FromJSON a => FromJSON (TestInput a) where
instance (FromJSON a) => FromJSON (TestInput a) where
parseJSON value = do
(inner, contentFilter) <- parseContentsOrFile value
let testInput = case inner of
Expand All @@ -27,7 +27,7 @@ instance FromJSON a => FromJSON (TestInput a) where

data TestOutput actual where
TestOutputInline :: Assert actual -> TestOutput actual
TestOutputFromFile :: ToFixture expected => (expected -> Assert actual) -> Path Relative File -> TestOutput actual
TestOutputFromFile :: (ToFixture expected) => (expected -> Assert actual) -> Path Relative File -> TestOutput actual

instance (Eq actual, ToFixture actual, FromFixture actual, FromJSON actual) => FromJSON (TestOutput actual) where
parseJSON value@(Object v) =
Expand Down Expand Up @@ -59,7 +59,7 @@ parseTestOutput assertion value = do
where
filteredAssertion fixtureFilter expected = AssertFiltered fixtureFilter (assertion expected)

parseContentsOrFile :: FromJSON a => Value -> Parser (Either a (Path Relative File), Maybe Filter)
parseContentsOrFile :: (FromJSON a) => Value -> Parser (Either a (Path Relative File), Maybe Filter)
parseContentsOrFile s@(String _) = do
contents <- parseJSON s
pure (Left contents, Nothing)
Expand Down
7 changes: 3 additions & 4 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-20.12
resolver: lts-22.35
packages:
- .
ghc-options:
Expand All @@ -7,6 +7,5 @@ nix:
shell-file: ./shell.nix
extra-deps:
# There was a bug in the `tar` package that is fixed in https://github.com/haskell/tar/pull/26.
# However, this code has not been released, so we need to grab the latest commit instead.
- git: https://github.com/haskell/tar.git
commit: dbf8c995153c8a80450724d9f94cf33403740c80
# This has been released in tar v6.0.0.0 and up, but these versions are not in the current Stackage LTS (above).
- tar-0.6.3.0
Loading

0 comments on commit c2424c6

Please sign in to comment.