summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/scripts/ghci063.script
blob: 377f65934ceaa9ca32b8682d954f23536685b587 (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
:! echo module A where {} >A.hs
:! echo module B where { import A } >B.hs

-- Workaround for Trac #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.
:! 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 *not* look at the
-- contents of the file, because the timestamp hasn't changed.
:! cp B.hs B.hs-copy
:! touch -r B.hs B.hs-copy
:! echo "*** INVALID ***" >B.hs
:! touch -r B.hs-copy B.hs

:reload

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