@@ -5,6 +5,8 @@ import Test.Prelude
5
5
import Data.Array as Array
6
6
import Data.String (Pattern (..))
7
7
import Data.String as String
8
+ import Data.String.Regex as Regex
9
+ import Data.String.Regex.Flags as Regex.Flags
8
10
import Effect.Aff (bracket )
9
11
import Node.Path as Path
10
12
import Node.Process as Process
@@ -254,19 +256,20 @@ spec = Spec.describe "monorepo" do
254
256
255
257
Spec .it " #1208: clones a monorepo only once, even if multiple packages from it are needed" \{ spago, fixture, testCwd } -> do
256
258
-- A local file system Git repo to use as a remote for Spago to clone from
257
- let createLibraryRepo = do
258
- let libRepo = Path .concat [ Paths .paths.temp, " spago-1208" ]
259
- whenM (FS .exists libRepo) $ rmRf libRepo
260
- FS .copyTree { src: fixture " monorepo/1208-no-double-cloning/library" , dst: libRepo }
261
- git_ libRepo [ " init" ]
262
- git_ libRepo [ " add" , " ." ]
263
- git_ libRepo [ " config" , " --global" , " core.longpaths" , " true" ]
264
- git_ libRepo [ " config" , " user.name" , " test-user" ]
265
- git_ libRepo [ " config" , " user.email" , " test-user@aol.com" ]
266
- git_ libRepo [ " commit" , " -m" , " Initial commit" ]
267
- git_ libRepo [ " tag" , " v1" ]
268
- git_ libRepo [ " tag" , " v2" ]
269
- pure libRepo
259
+ let
260
+ createLibraryRepo = do
261
+ let libRepo = Path .concat [ Paths .paths.temp, " spago-1208" ]
262
+ whenM (FS .exists libRepo) $ rmRf libRepo
263
+ FS .copyTree { src: fixture " monorepo/1208-no-double-cloning/library" , dst: libRepo }
264
+ git_ libRepo [ " init" ]
265
+ git_ libRepo [ " add" , " ." ]
266
+ git_ libRepo [ " config" , " --global" , " core.longpaths" , " true" ]
267
+ git_ libRepo [ " config" , " user.name" , " test-user" ]
268
+ git_ libRepo [ " config" , " user.email" , " test-user@aol.com" ]
269
+ git_ libRepo [ " commit" , " -m" , " Initial commit" ]
270
+ git_ libRepo [ " tag" , " v1" ]
271
+ git_ libRepo [ " tag" , " v2" ]
272
+ pure libRepo
270
273
271
274
bracket createLibraryRepo rmRf \libRepo -> do
272
275
let
@@ -302,7 +305,11 @@ spec = Spec.describe "monorepo" do
302
305
{ stdoutFile: Nothing
303
306
, stderrFile: Just $ fixture expectedFixture
304
307
, result
305
- , sanitize: String .trim >>> String .replaceAll (String.Pattern libRepo) (String.Replacement " <library-repo-path>" )
308
+ , sanitize:
309
+ String .replaceAll (String.Pattern " \r\n " ) (String.Replacement " \n " )
310
+ >>> String .replaceAll (String.Pattern libRepo) (String.Replacement " <library-repo-path>" )
311
+ >>> Regex .replace (unsafeFromRight $ Regex .regex " ^purs compile: .*$" (Regex.Flags .global <> Regex.Flags .multiline)) " purs compile..."
312
+ >>> String .trim
306
313
}
307
314
308
315
-- First run `spago install` to make sure global cache is populated,
@@ -348,6 +355,12 @@ spec = Spec.describe "monorepo" do
348
355
shouldBeSuccessErr' " monorepo/1208-no-double-cloning/expected-stderr/four-deps.txt"
349
356
assertRefCheckedOut " lib4" " v4"
350
357
358
+ -- Lockfile test: when it's up to date but the cache is not populated (i.e. a fresh clone)
359
+ -- then there are no double clones. This is a regression test for #1206
360
+ spago [ " build" ] >>= shouldBeSuccess
361
+ rmRf " .spago"
362
+ spago [ " build" ] >>= shouldBeSuccessErr' " monorepo/1208-no-double-cloning/expected-stderr/lockfile-up-to-date.txt"
363
+
351
364
where
352
365
git_ cwd = void <<< git cwd
353
366
0 commit comments