Skip to content

Commit

Permalink
Merge branch 'rm-otherlinux'
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Nov 20, 2024
2 parents 6afbc4f + 119c300 commit 0e0451f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 19,320 deletions.
2 changes: 1 addition & 1 deletion lib/GHCup/Platform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ getLinuxDistro = do
| hasWord ["rocky", "Rocky Linux"] -> Rocky
-- https://github.com/void-linux/void-packages/blob/master/srcpkgs/base-files/files/os-release
| hasWord ["void", "Void Linux"] -> Void
| otherwise -> OtherLinux (T.unpack $ fromMaybe name mid)
| otherwise -> UnknownLinux
pure (distro, parsedVer)
where
regex x = makeRegexOpts compIgnoreCase execBlank ([s|\<|] ++ x ++ [s|\>|])
Expand Down
4 changes: 0 additions & 4 deletions lib/GHCup/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ data LinuxDistro = Debian
| OpenSUSE
-- not known
| UnknownLinux
-- ^ must exit
| OtherLinux String
deriving (Eq, GHC.Generic, Ord, Show)

instance Enum LinuxDistro where
Expand Down Expand Up @@ -293,7 +291,6 @@ instance Enum LinuxDistro where
fromEnum Exherbo = 11
fromEnum OpenSUSE = 12
fromEnum UnknownLinux = 13
fromEnum (OtherLinux _) = error "fromEnum: OtherLinux"

instance Bounded LinuxDistro where
minBound = Debian
Expand All @@ -319,7 +316,6 @@ distroToString Gentoo = "gentoo"
distroToString Exherbo = "exherbo"
distroToString OpenSUSE = "opensuse"
distroToString UnknownLinux = "unknown"
distroToString (OtherLinux str) = str

instance Pretty LinuxDistro where
pPrint = text . distroToString
Expand Down
6 changes: 2 additions & 4 deletions lib/GHCup/Types/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ import qualified Text.Megaparsec as MP
import qualified Text.Megaparsec.Char as MPC

instance ToJSON LinuxDistro where
toJSON (OtherLinux x) = String (T.pack x)
toJSON x = String . T.pack . show $ x
toJSON = String . T.pack . show

instance FromJSON LinuxDistro where
parseJSON = withText "LinuxDistro" $ \t -> case T.unpack (T.toLower t) of
Expand All @@ -69,7 +68,7 @@ instance FromJSON LinuxDistro where
"exherbo" -> pure Exherbo
"opensuse" -> pure OpenSUSE
"unknownlinux" -> pure UnknownLinux
_ -> pure (OtherLinux $ T.unpack t)
_ -> fail "Unknown Linux distro"

deriveJSON defaultOptions { fieldLabelModifier = removeLensFieldLabel } ''MetaMode
deriveJSON defaultOptions { fieldLabelModifier = removeLensFieldLabel } ''Architecture
Expand Down Expand Up @@ -142,7 +141,6 @@ instance ToJSONKey Platform where
toJSONKey = toJSONKeyText $ \case
Darwin -> T.pack "Darwin"
FreeBSD -> T.pack "FreeBSD"
Linux (OtherLinux s) -> T.pack ("Linux_" <> s)
Linux d -> T.pack ("Linux_" <> show d)
Windows -> T.pack "Windows"

Expand Down
5 changes: 2 additions & 3 deletions test/ghcup-test/GHCup/ArbitraryTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ instance Arbitrary DownloadInfo where
shrink = genericShrink

instance Arbitrary LinuxDistro where
arbitrary = do
let other = OtherLinux <$> listOf (elements ['a' .. 'z'])
oneof (other:(pure <$> allDistros))
arbitrary =
oneof (pure <$> allDistros)

instance Arbitrary Platform where
arbitrary = genericArbitrary
Expand Down
8 changes: 3 additions & 5 deletions test/ghcup-test/GHCup/Types/JSONSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GHCup.Types hiding ( defaultSettings )
import GHCup.Types.JSON ()
import GHCup.Prelude

import Control.Monad (when)
import Test.Aeson.GenericSpecs
import Test.Hspec

Expand All @@ -15,9 +16,6 @@ import Test.Hspec
spec :: Spec
spec = do
roundtripSpecs (Proxy @LinuxDistro)
roundtripAndGoldenSpecsWithSettings (defaultSettings { goldenDirectoryOption = CustomDirectoryName goldenDir, sampleSize = 2 }) (Proxy @GHCupInfo)
where
goldenDir
| isWindows = "test/ghcup-test/golden/windows"
| otherwise = "test/ghcup-test/golden/unix"
when (not isWindows) $
roundtripAndGoldenSpecsWithSettings (defaultSettings { goldenDirectoryOption = CustomDirectoryName "test/ghcup-test/golden/unix", sampleSize = 2 }) (Proxy @GHCupInfo)

57 changes: 0 additions & 57 deletions test/ghcup-test/golden/unix/GHCupInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4335,63 +4335,6 @@
"notes": "rfiwf"
}
},
"Linux_dazt": {
"( < 4.1.1 && >= 4.4.4 && > 2.3.3 && > 4.2.3 && == 3.4.4 && > 5.1.3 && < 2.4.1 )": {
"distroPKGs": [
"eisz",
"abh",
"",
"quyvc"
],
"notes": "lrghnn"
},
"( <= 2.3.4 && < 3.2.2 && == 5.4.2 ) || ( > 4.4.1 && < 1.2.2 && <= 1.1.1 && == 1.2.1 && <= 3.3.3 )": {
"distroPKGs": [
"ztsizdt",
"vph",
"jlrzip",
"qnlpqz",
"fy"
],
"notes": "dfscy"
},
"( <= 5.4.5 && > 5.1.3 && > 1.4.1 ) || ( == 3.3.2 && == 3.1.4 )": {
"distroPKGs": [
"fzsz",
"ldrkfg",
"lae",
"weqtzc",
"uxs",
"jszlviv",
"pfw"
],
"notes": ""
},
"( > 1.5.4 && > 4.6.4 && == 2.2.5 && > 2.1.5 )": {
"distroPKGs": [
"zlthy",
"cdqww"
],
"notes": ""
},
"( > 3.2.3 && > 1.2.1 && <= 5.5.1 )": {
"distroPKGs": [
"",
"n",
"",
"qhyjus",
""
],
"notes": "zxe"
},
"unknown_versioning": {
"distroPKGs": [
"fd",
"e"
],
"notes": "veu"
}
},
"Windows": {
"( < 3.3.1 && < 5.1.3 && > 2.3.4 && > 3.3.2 ) || ( == 1.4.1 )": {
"distroPKGs": [
Expand Down
Loading

0 comments on commit 0e0451f

Please sign in to comment.