summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/scripts/ghci063.script
blob: 5b74e1841d486cfc056faf6ceaedb3d4b604791f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
:l shell.hs
:def shell (\s -> do shell s; return "")
:l

:shell echo module A where {} >A.hs
:shell echo module B where { import A } >B.hs

-- Workaround for #16201. We use "touch -r" to set modification
-- timestamps, which leads to precision loss on Darwin. For example,
--
--    before: 2019-02-25 01:11:23.807627350 +0300
--    after:  2019-02-25 01:11:23.807627000 +0300
--                                      ^^^
-- This means we can't trick GHCi into thinking the file hasn't been changed
-- by restoring its old timestamp, as we cannot faithfully restore all digits.
--
-- The solution is to nullify the insignificant digits before the first load.
:shell touch -r B.hs B.hs

:load B

-- We're going to replace B.hs with an invalid module but without
-- changing its timestamp.  A :reload should look at the contents of the
-- file, because the hash has changed. Note that this test previously tested
-- for the opposite behaviour, but was changed as a result of #19439 / #16495.
:shell cp B.hs B.hs-copy
:shell touch -r B.hs B.hs-copy
:shell echo "*** INVALID ***" >B.hs
:shell touch -r B.hs-copy B.hs

:reload

-- Put the original file back, now it should work
:shell cp B.hs-copy B.hs
:reload