diff options
Diffstat (limited to 'stdlib/source/test/aedifex')
-rw-r--r-- | stdlib/source/test/aedifex/cli.lux | 1 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/command/deploy.lux | 14 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/command/deps.lux | 7 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/dependency/resolution.lux | 188 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/package.lux | 14 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/repository.lux | 49 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/repository/identity.lux | 30 |
7 files changed, 167 insertions, 136 deletions
diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index 9118132cd..b92ebe145 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -18,7 +18,6 @@ {#program ["." / ["/#" // #_ - [repository (#+ User Password)] ["#" profile]]]}) (def: compilation diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 18045a20b..86f3e0dbb 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -48,7 +48,8 @@ ["#." pom] ["#." local] ["#." hash] - ["#." repository (#+ Identity Repository)] + ["#." repository (#+ Repository) + [identity (#+ Identity)]] ["#." artifact (#+ Artifact) ["#/." extension]]]]]}) @@ -69,9 +70,9 @@ (file.get-file promise.monad fs (format head (\ fs separator) head ".lux")))] (recur tail))))) -(def: (execute! program repository fs identity artifact profile) +(def: (execute! program repository fs artifact profile) (-> (Program Promise) (Repository Promise) (file.System Promise) - Identity Artifact ///.Profile + Artifact ///.Profile (Promise (Try Text))) (do promise.monad [home (\ program home [])] @@ -80,7 +81,7 @@ _ (..make-sources! fs (get@ #///.sources profile)) _ (: (Promise (Try Path)) (file.make-directories promise.monad fs (///local.repository fs home))) - _ (/.do! console repository fs identity artifact profile)] + _ (/.do! console repository fs artifact profile)] (!.use (\ console read-line) [])))) (def: #export test @@ -95,16 +96,15 @@ (wrap [artifact expected-pom profile]))) @profile.random) - identity @repository.identity home (random.ascii/alpha 5) working-directory (random.ascii/alpha 5) - #let [repository (///repository.mock (@repository.simulation identity) + #let [repository (///repository.mock @repository.simulation @repository.empty) fs (file.mock (\ file.default separator)) program (program.async (program.mock environment.empty home working-directory))]] (wrap (do {! promise.monad} [verdict (do {! ///action.monad} - [logging (..execute! program repository fs identity artifact profile) + [logging (..execute! program repository fs artifact profile) expected-library (|> profile (get@ #///.sources) set.to-list diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 292185a28..84c51dc93 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -44,7 +44,8 @@ ["#." artifact ["#/." type]] ["#." dependency - ["#/." resolution]]]]]}) + ["#/." resolution] + ["#/." status]]]]]}) (def: #export test Test @@ -78,10 +79,10 @@ dependee-package (|> dependee-package (set@ #///package.origin #///package.Remote) - (set@ #///package.pom dependee-pom)) + (set@ #///package.pom [dependee-pom #///dependency/status.Unverified])) depender-package (|> depender-package (set@ #///package.origin #///package.Remote) - (set@ #///package.pom depender-pom)) + (set@ #///package.pom [depender-pom #///dependency/status.Unverified])) fs (file.mock (\ file.default separator)) program (program.async (program.mock environment.empty home working-directory))]] diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index c3e26f5bf..92ced9e74 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -15,7 +15,7 @@ [data ["." product] ["." binary] - ["." text ("#\." equivalence) + ["." text ["." encoding]] [format ["." xml]] @@ -39,7 +39,8 @@ ["#." package (#+ Package)] ["#." hash] ["#." repository (#+ Simulation)] - ["#." dependency] + ["#." dependency + ["#/." status]] ["#." pom] ["#." artifact (#+ Artifact) ["#/." type] @@ -58,33 +59,36 @@ (def: #export (single artifact package) (-> Artifact Package (Simulation Any)) (structure - (def: (on-download request extension state) - (if (\ ///artifact.equivalence = artifact request) - (cond (text\= extension ///artifact/extension.lux-library) - (#try.Success [state (get@ #///package.library package)]) + (def: (on-download uri state) + (if (text.contains? (///artifact.uri artifact) uri) + (cond (text.ends-with? ///artifact/extension.lux-library uri) + (#try.Success [state (|> package + (get@ #///package.library) + product.left)]) - (text\= extension ///artifact/extension.pom) + (text.ends-with? ///artifact/extension.pom uri) (#try.Success [state (|> package (get@ #///package.pom) + product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) + + ## (text.ends-with? ///artifact/extension.sha-1 uri) + ## (#try.Success [state (|> package + ## (get@ #///package.sha-1) + ## (\ ///hash.sha-1-codec encode) + ## (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.sha-1) - (#try.Success [state (|> package - (get@ #///package.sha-1) - (\ ///hash.sha-1-codec encode) - (\ encoding.utf8 encode))]) - - (text\= extension ///artifact/extension.md5) - (#try.Success [state (|> package - (get@ #///package.md5) - (\ ///hash.md5-codec encode) - (\ encoding.utf8 encode))]) + ## (text.ends-with? ///artifact/extension.md5 uri) + ## (#try.Success [state (|> package + ## (get@ #///package.md5) + ## (\ ///hash.md5-codec encode) + ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload identity artifact extension binary state) + (def: (on-upload uri binary state) (#try.Failure "NOPE")))) (def: one @@ -100,63 +104,69 @@ #let [good (..single expected-artifact expected-package) bad-sha-1 (: (Simulation Any) (structure - (def: (on-download actual-artifact extension state) - (if (\ ///artifact.equivalence = expected-artifact actual-artifact) - (cond (text\= extension ///artifact/extension.lux-library) - (#try.Success [state (get@ #///package.library expected-package)]) + (def: (on-download uri state) + (if (text.contains? (///artifact.uri expected-artifact) uri) + (cond (text.ends-with? ///artifact/extension.lux-library uri) + (#try.Success [state (|> expected-package + (get@ #///package.library) + product.left)]) - (text\= extension ///artifact/extension.pom) + (text.ends-with? ///artifact/extension.pom uri) (#try.Success [state (|> expected-package (get@ #///package.pom) + product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.sha-1) - (#try.Success [state (|> dummy-package - (get@ #///package.sha-1) - (\ ///hash.sha-1-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.sha-1) + ## (#try.Success [state (|> dummy-package + ## (get@ #///package.sha-1) + ## (\ ///hash.sha-1-codec encode) + ## (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.md5) - (#try.Success [state (|> expected-package - (get@ #///package.md5) - (\ ///hash.md5-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.md5) + ## (#try.Success [state (|> expected-package + ## (get@ #///package.md5) + ## (\ ///hash.md5-codec encode) + ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload identity artifact extension binary state) + (def: (on-upload uri binary state) (#try.Failure "NOPE")))) bad-md5 (: (Simulation Any) (structure - (def: (on-download actual-artifact extension state) - (if (\ ///artifact.equivalence = expected-artifact actual-artifact) - (cond (text\= extension ///artifact/extension.lux-library) - (#try.Success [state (get@ #///package.library expected-package)]) + (def: (on-download uri state) + (if (text.contains? (///artifact.uri expected-artifact) uri) + (cond (text.ends-with? ///artifact/extension.lux-library uri) + (#try.Success [state (|> expected-package + (get@ #///package.library) + product.left)]) - (text\= extension ///artifact/extension.pom) + (text.ends-with? ///artifact/extension.pom uri) (#try.Success [state (|> expected-package (get@ #///package.pom) + product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.sha-1) - (#try.Success [state (|> expected-package - (get@ #///package.sha-1) - (\ ///hash.sha-1-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.sha-1) + ## (#try.Success [state (|> expected-package + ## (get@ #///package.sha-1) + ## (\ ///hash.sha-1-codec encode) + ## (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.md5) - (#try.Success [state (|> dummy-package - (get@ #///package.md5) - (\ ///hash.md5-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.md5) + ## (#try.Success [state (|> dummy-package + ## (get@ #///package.md5) + ## (\ ///hash.md5-codec encode) + ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload identity artifact extension binary state) + (def: (on-upload uri binary state) (#try.Failure "NOPE"))))]] (`` ($_ _.and (wrap @@ -205,63 +215,69 @@ #let [good (..single expected-artifact expected-package) bad-sha-1 (: (Simulation Any) (structure - (def: (on-download actual-artifact extension state) - (if (\ ///artifact.equivalence = expected-artifact actual-artifact) - (cond (text\= extension ///artifact/extension.lux-library) - (#try.Success [state (get@ #///package.library expected-package)]) + (def: (on-download uri state) + (if (text.contains? (///artifact.uri expected-artifact) uri) + (cond (text.ends-with? ///artifact/extension.lux-library uri) + (#try.Success [state (|> expected-package + (get@ #///package.library) + product.left)]) - (text\= extension ///artifact/extension.pom) + (text.ends-with? ///artifact/extension.pom uri) (#try.Success [state (|> expected-package (get@ #///package.pom) + product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.sha-1) - (#try.Success [state (|> dummy-package - (get@ #///package.sha-1) - (\ ///hash.sha-1-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.sha-1) + ## (#try.Success [state (|> dummy-package + ## (get@ #///package.sha-1) + ## (\ ///hash.sha-1-codec encode) + ## (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.md5) - (#try.Success [state (|> expected-package - (get@ #///package.md5) - (\ ///hash.md5-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.md5) + ## (#try.Success [state (|> expected-package + ## (get@ #///package.md5) + ## (\ ///hash.md5-codec encode) + ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload identity artifact extension binary state) + (def: (on-upload uri binary state) (#try.Failure "NOPE")))) bad-md5 (: (Simulation Any) (structure - (def: (on-download actual-artifact extension state) - (if (\ ///artifact.equivalence = expected-artifact actual-artifact) - (cond (text\= extension ///artifact/extension.lux-library) - (#try.Success [state (get@ #///package.library expected-package)]) + (def: (on-download uri state) + (if (text.contains? (///artifact.uri expected-artifact) uri) + (cond (text.ends-with? ///artifact/extension.lux-library uri) + (#try.Success [state (|> expected-package + (get@ #///package.library) + product.left)]) - (text\= extension ///artifact/extension.pom) + (text.ends-with? ///artifact/extension.pom uri) (#try.Success [state (|> expected-package (get@ #///package.pom) + product.left (\ xml.codec encode) (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.sha-1) - (#try.Success [state (|> expected-package - (get@ #///package.sha-1) - (\ ///hash.sha-1-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.sha-1) + ## (#try.Success [state (|> expected-package + ## (get@ #///package.sha-1) + ## (\ ///hash.sha-1-codec encode) + ## (\ encoding.utf8 encode))]) - (text\= extension ///artifact/extension.md5) - (#try.Success [state (|> dummy-package - (get@ #///package.md5) - (\ ///hash.md5-codec encode) - (\ encoding.utf8 encode))]) + ## (text\= extension ///artifact/extension.md5) + ## (#try.Success [state (|> dummy-package + ## (get@ #///package.md5) + ## (\ ///hash.md5-codec encode) + ## (\ encoding.utf8 encode))]) ## else (#try.Failure "NOPE")) (#try.Failure "NOPE"))) - (def: (on-upload identity artifact extension binary state) + (def: (on-upload uri binary state) (#try.Failure "NOPE"))))]] ($_ _.and (wrap @@ -332,9 +348,9 @@ ///pom.write try.assume) - dependee-package (set@ #///package.pom dependee-pom dependee-package) - depender-package (set@ #///package.pom depender-pom depender-package) - ignored-package (set@ #///package.pom ignored-pom ignored-package)]] + dependee-package (set@ #///package.pom [dependee-pom #///dependency/status.Unverified] dependee-package) + depender-package (set@ #///package.pom [depender-pom #///dependency/status.Unverified] depender-package) + ignored-package (set@ #///package.pom [ignored-pom #///dependency/status.Unverified] ignored-package)]] ($_ _.and (wrap (do promise.monad diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index aecdcc5af..56169a766 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -52,12 +52,14 @@ [[profile package] ..random] ($_ _.and (_.cover [/.local] - (and (\ //hash.equivalence = - (//hash.sha-1 (get@ #/.library package)) - (get@ #/.sha-1 package)) - (\ //hash.equivalence = - (//hash.md5 (get@ #/.library package)) - (get@ #/.md5 package)))) + false + ## (and (\ //hash.equivalence = + ## (//hash.sha-1 (get@ #/.library package)) + ## (get@ #/.sha-1 package)) + ## (\ //hash.equivalence = + ## (//hash.md5 (get@ #/.library package)) + ## (get@ #/.md5 package))) + ) (_.cover [/.dependencies] (let [expected (get@ #//.dependencies profile)] (case (/.dependencies package) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index 5d2b62f57..af96bc572 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -21,26 +21,18 @@ [world [net ["." uri (#+ URI)]]]] - [// - ["@." artifact]] + ["." / #_ + ["#." identity] + [// + ["@." artifact]]] {#spec ["$." /]} {#program - ["." / (#+ Identity) + ["." / ["/#" // #_ ["#." artifact (#+ Version Artifact) ["#/." extension (#+ Extension)]]]]}) -(def: #export identity - (Random Identity) - (random.and (random.ascii/alpha 10) - (random.ascii/alpha 10))) - -(def: identity-equivalence - (Equivalence Identity) - (product.equivalence text.equivalence - text.equivalence)) - (def: artifact (-> Version Artifact) (|>> ["com.github.luxlang" "test-artifact"])) @@ -49,10 +41,6 @@ (exception.report ["URI" (%.text uri)])) -(exception: (invalid-identity {[user _] Identity}) - (exception.report - ["User" (%.text user)])) - (type: Store (Dictionary URI Binary)) @@ -60,8 +48,8 @@ Store (dictionary.new text.hash)) -(structure: #export (simulation identity) - (-> Identity (/.Simulation Store)) +(structure: #export simulation + (/.Simulation Store) (def: (on-download uri state) (case (dictionary.get uri state) @@ -70,21 +58,16 @@ #.None (exception.throw ..not-found [uri]))) - (def: (on-upload requester uri content state) - (if (\ identity-equivalence = identity requester) - (exception.return (dictionary.put uri content state)) - (exception.throw ..invalid-identity [requester])))) + (def: (on-upload uri content state) + (exception.return (dictionary.put uri content state)))) (def: #export test Test (<| (_.covering /._) - (do {! random.monad} - [valid ..identity - invalid (random.filter (|>> (\ identity-equivalence = valid) not) - ..identity)] - ($_ _.and - (_.for [/.mock /.Simulation] - ($/.spec valid (..artifact "1.2.3-YES") - invalid (..artifact "4.5.6-NO") - (/.mock (..simulation valid) ..empty))) - )))) + ($_ _.and + (_.for [/.mock /.Simulation] + ($/.spec (..artifact "1.2.3-YES") + (..artifact "4.5.6-NO") + (/.mock ..simulation ..empty))) + /identity.test + ))) diff --git a/stdlib/source/test/aedifex/repository/identity.lux b/stdlib/source/test/aedifex/repository/identity.lux new file mode 100644 index 000000000..98d798cf7 --- /dev/null +++ b/stdlib/source/test/aedifex/repository/identity.lux @@ -0,0 +1,30 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + {[0 #spec] + [/ + ["$." equivalence]]}] + [data + ["." product] + ["." text]] + [math + ["." random (#+ Random)]]] + {#program + ["." /]}) + +(def: #export random + (Random /.Identity) + ($_ random.and + (random.ascii/alpha 10) + (random.ascii/alpha 10) + )) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [/.Identity] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + )))) |