Skip to content

Commit

Permalink
Add tests for RejectFutureIndexStates and fix other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Oct 31, 2023
1 parent 82d308f commit ccabdef
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ bench.html

# Emacs
.projectile

# I'm unsure how to ignore these generated golden files
cabal-testsuite/PackageTests/NewUpdate/RejectFutureIndexStates/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ main = cabalTest $ withRepo "repo" $ do
cabal
"get"
[ "criterion", "--only-package-description" ]
void (shell "rm" ["criterion-1.1.4.0.cabal"])
6 changes: 2 additions & 4 deletions cabal-testsuite/PackageTests/Get/T7248/cabal.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# cabal get
Warning: <ROOT>/cabal.config: Unrecognized stanza on line 3
Warning: The package list for 'repo.invalid' does not exist. Run 'cabal update' to download it.
Error: [Cabal-7100]
There is no package named 'a-b-s-e-n-t'.
You may need to run 'cabal update' to get the latest list of available packages.
Error: [Cabal-7160]
The package list for 'repo.invalid' does not exist. Run 'cabal update' to download it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# cabal update
Warning: Caught exception during _mirrors lookup:DnsNoData
Warning: No mirrors found for http://localhost:8000/
Downloading the latest package list from repository.localhost
Package list of repository.localhost has been updated.
The index-state is set to REPLACEME.
# cabal build
Error: [Cabal-7159]
Latest known index-state for 'repository.localhost' (REPLACEME) is older than the requested index-state (4000-01-01T00:00:00Z).
Run 'cabal update' or set the index-state to a value at or before REPLACEME.
# cabal build
Warning: There is no index-state for 'repository.localhost' exactly at the requested timestamp (2023-01-01T00:00:00Z). Also, there are no index-states before the one requested, so the repository 'repository.localhost' will be empty.
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: fake-pkg-1.0 (user goal)
[__1] unknown package: pkg (dependency of fake-pkg)
[__1] fail (backjumping, conflict set: fake-pkg, pkg)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: fake-pkg (2), pkg (1)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: fake-pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Test.Cabal.Prelude
import Data.List

main = cabalTest $ withProjectFile "cabal.project" $ withRemoteRepo "repo" $ do
output <- last
. words
. head
. filter ("Index cache updated to index-state " `isPrefixOf`)
. lines
. resultOutput
<$> cabal' "update" []
-- update golden output with actual timestamp
shell "cp" ["cabal.out.in", "cabal.out"]
shell "sed" ["-i''", "-e", "s/REPLACEME/" <> output <> "/g", "cabal.out"]
-- This shall fail with an error message as specified in `cabal.out`
fails $ cabal "build" ["--index-state=4000-01-01T00:00:00Z", "fake-pkg"]
-- This shall fail by not finding the package, what indicates that it
-- accepted an older index-state.
fails $ cabal "build" ["--index-state=2023-01-01T00:00:00Z", "fake-pkg"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Main where

main = print "hello"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 1.0
name: fake-pkg
build-type: Simple
cabal-version: >= 1.2

executable my-exe
main-is: Main.hs
build-depends: base, pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo (someFunc) where

someFunc = "hello"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: pkg
version: 1.0
build-type: Simple
cabal-version: >= 1.2

library
exposed-modules: Foo
build-depends: base

0 comments on commit ccabdef

Please sign in to comment.