|
117 | 117 | [graph.bar.core :as bar]))))))
|
118 | 118 |
|
119 | 119 | (deftest cljs-1469
|
120 |
| - (let [srcs "samples/hello/src" |
| 120 | + (let [out (.getPath (io/file (test/tmp-dir) "loader-test-out")) |
| 121 | + srcs "samples/hello/src" |
121 | 122 | [common-tmp app-tmp] (mapv #(File/createTempFile % ".js")
|
122 |
| - ["common" "app"]) |
| 123 | + ["common" "app"]) |
123 | 124 | opts {:optimizations :simple
|
| 125 | + :output-dir out |
124 | 126 | :modules {:common {:entries #{"hello.foo.bar"}
|
125 | 127 | :output-to (.getAbsolutePath common-tmp)}
|
126 | 128 | :app {:entries #{"hello.core"}
|
127 | 129 | :output-to (.getAbsolutePath app-tmp)}}}]
|
| 130 | + (test/delete-out-files out) |
128 | 131 | (.deleteOnExit common-tmp)
|
129 | 132 | (.deleteOnExit app-tmp)
|
130 | 133 | (is (every? #(zero? (.length %)) [common-tmp app-tmp])
|
|
161 | 164 | (str foreign-lib-file))))))
|
162 | 165 |
|
163 | 166 | (deftest cljs-1537-circular-deps
|
164 |
| - (let [out-file (io/file "out/main.js") |
| 167 | + (let [out (.getPath (io/file (test/tmp-dir) "cljs-1537-test-out")) |
| 168 | + out-file (io/file out "main.js") |
165 | 169 | root "src/test/cljs_build"]
|
166 |
| - (.delete out-file) |
| 170 | + (test/delete-out-files out) |
167 | 171 | (try
|
168 | 172 | (build/build (build/inputs
|
169 | 173 | (io/file (str root "a.cljs"))
|
170 | 174 | (io/file (str root "b.cljs")))
|
171 | 175 | {:main 'circular-deps.a
|
172 | 176 | :optimizations :none
|
173 |
| - :output-to "out"}) |
| 177 | + :output-to out}) |
174 | 178 | (is false)
|
175 | 179 | (catch Throwable e
|
176 | 180 | (is true)))))
|
|
190 | 194 | :entries #{'loader-test.bar}}}}})
|
191 | 195 |
|
192 | 196 | (deftest cljs-2077-test-loader
|
193 |
| - (test/delete-out-files) |
194 |
| - (let [{:keys [inputs opts]} (merge-with merge (loader-test-project "out")) |
195 |
| - loader (io/file "out" "cljs" "loader.js")] |
196 |
| - (build/build (build/inputs (io/file inputs "bar.cljs") (io/file inputs "foo.cljs")) opts) |
197 |
| - (is (.exists loader)) |
198 |
| - (is (not (nil? (re-find #"/loader_test/foo\.js" (slurp loader)))))) |
199 |
| - (test/delete-out-files) |
200 |
| - (let [project (merge-with merge (loader-test-project "out") |
201 |
| - {:opts {:optimizations :advanced |
202 |
| - :source-map true}})] |
203 |
| - (build/build (build/inputs (:inputs project)) (:opts project))) |
204 |
| - (testing "string inputs in modules" |
205 |
| - (test/delete-out-files) |
206 |
| - (let [project (merge-with merge (loader-test-project "out") |
207 |
| - {:opts {:optimizations :whitespace}})] |
208 |
| - (build/build (build/inputs (:inputs project)) (:opts project))))) |
| 197 | + (let [out (.getPath (io/file (test/tmp-dir) "loader-test-out"))] |
| 198 | + (test/delete-out-files out) |
| 199 | + (let [{:keys [inputs opts]} (merge-with merge (loader-test-project out)) |
| 200 | + loader (io/file out "cljs" "loader.js")] |
| 201 | + (build/build (build/inputs (io/file inputs "bar.cljs") (io/file inputs "foo.cljs")) opts) |
| 202 | + (is (.exists loader)) |
| 203 | + (is (not (nil? (re-find #"/loader_test/foo\.js" (slurp loader)))))) |
| 204 | + (test/delete-out-files out) |
| 205 | + (let [project (merge-with merge (loader-test-project out) |
| 206 | + {:opts {:optimizations :advanced |
| 207 | + :source-map true}})] |
| 208 | + (build/build (build/inputs (:inputs project)) (:opts project))) |
| 209 | + (testing "string inputs in modules" |
| 210 | + (test/delete-out-files out) |
| 211 | + (let [project (merge-with merge (loader-test-project out) |
| 212 | + {:opts {:optimizations :whitespace}})] |
| 213 | + (build/build (build/inputs (:inputs project)) (:opts project)))))) |
209 | 214 |
|
210 | 215 | (deftest test-npm-deps
|
211 | 216 | (test/delete-node-modules)
|
|
420 | 425 | (test/delete-node-modules))
|
421 | 426 |
|
422 | 427 | (deftest test-deps-api-cljs-2255
|
423 |
| - (test/delete-node-modules) |
424 |
| - (spit (io/file "package.json") "{}") |
425 |
| - (build/install-node-deps! {:left-pad "1.1.3"}) |
426 |
| - (is (.exists (io/file "node_modules/left-pad/package.json"))) |
427 |
| - (test/delete-node-modules) |
428 |
| - (spit (io/file "package.json") "{}") |
429 |
| - (build/install-node-deps! {:react "15.6.1" |
430 |
| - :react-dom "15.6.1"}) |
431 |
| - (let [modules (build/get-node-deps '[react "react-dom/server"])] |
432 |
| - (is (true? (some (fn [module] |
433 |
| - (= module {:module-type :es6 |
434 |
| - :file (.getAbsolutePath (io/file "node_modules/react/react.js")) |
435 |
| - :provides ["react" |
436 |
| - "react/react.js" |
437 |
| - "react/react"]})) |
438 |
| - modules))) |
439 |
| - (is (true? (some (fn [module] |
440 |
| - (= module {:module-type :es6 |
441 |
| - :file (.getAbsolutePath (io/file "node_modules/react/lib/React.js")) |
442 |
| - :provides ["react/lib/React.js" "react/lib/React"]})) |
443 |
| - modules))) |
444 |
| - (is (true? (some (fn [module] |
445 |
| - (= module {:module-type :es6 |
446 |
| - :file (.getAbsolutePath (io/file "node_modules/react-dom/server.js")) |
447 |
| - :provides ["react-dom/server.js" "react-dom/server"]})) |
448 |
| - modules)))) |
449 |
| - (test/delete-node-modules) |
450 |
| - (.delete (io/file "package.json"))) |
| 428 | + (let [out (.getPath (io/file (test/tmp-dir) "cljs-2255-test-out"))] |
| 429 | + (test/delete-out-files out) |
| 430 | + (test/delete-node-modules) |
| 431 | + (spit (io/file "package.json") "{}") |
| 432 | + (build/install-node-deps! {:left-pad "1.1.3"} {:output-dir out}) |
| 433 | + (is (.exists (io/file "node_modules/left-pad/package.json"))) |
| 434 | + (test/delete-out-files out) |
| 435 | + (test/delete-node-modules) |
| 436 | + (spit (io/file "package.json") "{}") |
| 437 | + (build/install-node-deps! |
| 438 | + {:react "15.6.1" |
| 439 | + :react-dom "15.6.1"} |
| 440 | + {:output-dir out}) |
| 441 | + (let [modules (build/get-node-deps '[react "react-dom/server"] {:output-dir out})] |
| 442 | + (is (true? (some (fn [module] |
| 443 | + (= module {:module-type :es6 |
| 444 | + :file (.getAbsolutePath (io/file "node_modules/react/react.js")) |
| 445 | + :provides ["react" |
| 446 | + "react/react.js" |
| 447 | + "react/react"]})) |
| 448 | + modules))) |
| 449 | + (is (true? (some (fn [module] |
| 450 | + (= module {:module-type :es6 |
| 451 | + :file (.getAbsolutePath (io/file "node_modules/react/lib/React.js")) |
| 452 | + :provides ["react/lib/React.js" "react/lib/React"]})) |
| 453 | + modules))) |
| 454 | + (is (true? (some (fn [module] |
| 455 | + (= module {:module-type :es6 |
| 456 | + :file (.getAbsolutePath (io/file "node_modules/react-dom/server.js")) |
| 457 | + :provides ["react-dom/server.js" "react-dom/server"]})) |
| 458 | + modules)))) |
| 459 | + (test/delete-out-files out) |
| 460 | + (test/delete-node-modules) |
| 461 | + (.delete (io/file "package.json")))) |
0 commit comments