Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a single jar test (Issue #70).

  • Loading branch information...
commit ab2086a16c8ac7912d25fc376018c0075ea73bb7 1 parent dcd779c
@emezeske authored
View
8 plugin/src/leiningen/cljsbuild/jar.clj
@@ -13,10 +13,14 @@
(.read fis ba)
ba)))
-(defn- relative-path
+(defn relative-path
"Given two normalized path strings, returns a path string of the second relative to the first."
[parent child]
- (s/replace (s/replace child parent "") #"^[\\/]" ""))
+ (let [relative (s/replace child parent "")]
+ (when (= child relative)
+ (throw (Exception.
+ (str child " is not a child of " parent))))
+ (s/replace relative #"^[\\/]" "")))
;; The reason we return a :bytes filespec is that it's the only way of
;; specifying a file's destination path inside the jar and is contents
View
12 plugin/test/leiningen/test/cljsbuild/jar.clj
@@ -0,0 +1,12 @@
+(ns leiningen.test.cljsbuild.jar
+ (:use
+ leiningen.cljsbuild.jar
+ clojure.test))
+
+(deftest test-relative-path
+ (is (= "a" (relative-path "/" "/a")))
+ (is (= "d/e" (relative-path "/a/b/c" "/a/b/c/d/e")))
+ (is (thrown? Exception (relative-path "" "a")))
+ (is (thrown? Exception (relative-path "/a/b/c" "/a/b"))))
+
+; TODO: More tests!
Please sign in to comment.
Something went wrong with that request. Please try again.