Skip to content

Commit

Permalink
Decompose with-profile args not containing +/-.
Browse files Browse the repository at this point in the history
  • Loading branch information
hypirion committed Jan 27, 2014
1 parent 8bd6b8f commit ecb7ed0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion leiningen-core/src/leiningen/core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@
[raw-profile]
(if (composite-profile? raw-profile)
;; TODO: drop support for partially-composite profiles in 3.0
(mapv #(cond-> % (map? %) setup-profile-with-empty) raw-profile)
(mapv #(cond-> % (composite-profile? %) setup-profile-with-empty)
raw-profile)
(let [empty-defaults (select-keys empty-meta-merge-defaults
(keys raw-profile))]
(setup-map-defaults raw-profile empty-defaults))))
Expand Down
4 changes: 3 additions & 1 deletion src/leiningen/with_profile.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
profiles))

(not-any? #{\+ \-} prefixes)
(map keyword profiles)
(distinct
(mapcat (comp #(project/expand-profile project %) keyword)
profiles))

:else
(throw
Expand Down
15 changes: 14 additions & 1 deletion test/leiningen/test/with_profile.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@
[(prj-map {:default [:base :dev]}) "-default,+foo" [:foo]]
[(prj-map {:default [:base :dev], :foo [:bar :baz]})
"-default,+foo" [:bar :baz]]
[(prj-map {:default [:base :dev], :dev [:foo]
:foo [:bar :baz], :baz [:zap]})
"-default,+foo" [:bar :zap]]
;; TODO: drop support for partially-composite profiles in 3.0
[(prj-map {:default [:base :dev], :foo [:bar {:gross true}]})
"-default,+foo" [:foo]]]]
(is (= expected (profiles-in-group project pgroup)))))
(is (= expected (profiles-in-group project pgroup))))
(testing "no +/- prefixes in arg"
(let [project (prj-map {:default [:base :dev] :foo [:bar :baz]
:bar [:one :two] :baz [:three :four]})]
(doseq [[pgroup expected]
[["foo" [:one :two :three :four]]
["bar" [:one :two]]
["baz" [:three :four]]
["bar,baz" [:one :two :three :four]]
["baz,bar" [:three :four :one :two]]]]
(is (= expected (profiles-in-group project pgroup)))))))

0 comments on commit ecb7ed0

Please sign in to comment.