aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/command/deps.lux
blob: 99856c83c2588690b76f62061b6cce8b519fd8b9 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [monad (#+ do)]
    ["." predicate]]
   [control
    ["." try]
    [concurrency
     ["." promise]]
    [security
     ["!" capability]]
    [parser
     ["." environment]]]
   [data
    ["." text ("#\." equivalence)
     ["%" format (#+ format)]]
    [collection
     ["." dictionary]
     ["." set]]]
   [math
    ["." random (#+ Random)]]
   [world
    ["." program]
    ["." file]]]
  ["." // #_
   ["@." version]
   ["$/#" // #_
    ["#." package]
    ["#." artifact]
    ["#." dependency #_
     ["#/." resolution]]]]
  {#program
   ["." /
    ["/#" // #_
     ["#." clean]
     ["/#" // #_
      ["#" profile]
      ["#." action]
      ["#." pom]
      ["#." package]
      ["#." artifact
       ["#/." type]]
      ["#." dependency
       ["#/." resolution]
       ["#/." deployment]
       ["#/." status]]
      ["#." repository
       ["#/." origin]
       ["#/." local]]]]]})

(def: #export test
  Test
  (<| (_.covering /._)
      (do random.monad
        [home (random.ascii/alpha 5)
         working_directory (random.ascii/alpha 5)

         dependee_artifact $///artifact.random
         depender_artifact (random.filter (predicate.complement
                                           (\ ///artifact.equivalence = dependee_artifact))
                                          $///artifact.random)

         [_ dependee_package] $///package.random
         [_ depender_package] $///package.random

         #let [dependee {#///dependency.artifact dependee_artifact
                         #///dependency.type ///artifact/type.lux_library}
               depender {#///dependency.artifact depender_artifact
                         #///dependency.type ///artifact/type.lux_library}

               dependee_pom (|> (\ ///.monoid identity)
                                (set@ #///.identity (#.Some dependee_artifact))
                                ///pom.write
                                try.assume)
               depender_pom (|> (\ ///.monoid identity)
                                (set@ #///.identity (#.Some depender_artifact))
                                (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee)))
                                ///pom.write
                                try.assume)
               
               dependee_package (|> dependee_package
                                    (set@ #///package.origin (#///repository/origin.Remote ""))
                                    (set@ #///package.pom [dependee_pom #///dependency/status.Unverified]))
               depender_package (|> depender_package
                                    (set@ #///package.origin (#///repository/origin.Remote ""))
                                    (set@ #///package.pom [depender_pom #///dependency/status.Unverified]))

               fs (file.mock (\ file.default separator))
               program (program.async (program.mock environment.empty home working_directory))]]
        (wrap (do promise.monad
                [verdict (do ///action.monad
                           [#let [console (@version.echo "")
                                  local (///repository/local.repository program fs)]
                            pre (|> ///dependency/resolution.empty
                                    (dictionary.put dependee dependee_package)
                                    (///dependency/deployment.all local))
                            post (|> (\ ///.monoid identity)
                                     (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee depender)))
                                     (/.do! console local (list (///repository.mock ($///dependency/resolution.single depender_artifact depender_package) []))))
                            logging! (\ ///action.monad map
                                        (text\= //clean.success)
                                        (!.use (\ console read_line) []))]
                           (wrap (and logging!
                                      (and (set.member? pre dependee_artifact)
                                           (not (set.member? pre depender_artifact)))
                                      (and (dictionary.key? post dependee)
                                           (dictionary.key? post depender)))))]
                (_.cover' [/.do!]
                          (try.default false verdict)))))))