-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing a fileset's resource files from tests #55
Comments
The principle of least surprise would probably be for boot-cljs-test to copy the resources to the runtime path also, but that cost may be prohibitive for some users. Cannot recall why the files are copied and not simply hard linked - perhaps that would keep the idea more feasible. Alternately could parameter-creep it and add resources option to the task. Happy to explore either - and in the short term you could "explode" the "porcelain" task into the lower level calls and insert the extra directory copy between tasks. Let me know if this is unclear and I can provide a sample. |
Another alternative I see is to add another task, like maybe As for the short term exploding I tried to instead of this: (cljs-test/test-cljs
:js-env :node
:exit? true}) This: (comp
(cljs-test/fs-snapshot)
(cljs-test/prep-cljs-tests)
(cljs :ids #{"cljs_test/generated_test_suite"})
(cljs-test/run-cljs-tests :js-env :node :cljs-opts {:target :nodejs :hashbang false})
(cljs-test/fs-restore))) But it still looks I'm getting something wrong as the exploded version can't find the the needed |
Have misspoken - the change needs to happen inside the |
Published two |
Using
|
The error seems to happen when This errors:
Moving
|
Thanks for isolating the problem, the linking code is a bit naive about parent directories existing 🙂 |
Published another SNAPSHOT including 96a46cb |
@crisptrutski doesn't work as expected for me. I've adapted (defn link-resources! [dir]
(when (.exists (io/file "node_modules"))
(file/sym-link (.getAbsoluteFile (io/file "node_modules")) (io/file dir "node_modules")))
(doseq [path (boot/get-env :resource-paths)
:let [f (io/file path)]
:when (.exists f)]
(doseq [r (.listFiles f)]
(println "sym link" (.getAbsolutePath r) "->" (.getAbsolutePath (io/file dir (.getName r))))
(file/sym-link (.getAbsoluteFile r) (io/file dir (.getName r)))))) This:
However, I'm running into an issue where the symlinked files are deleted after they are linked once and the tests are rerun. I guess hard linking would solve that. Will try hard links later. |
Let me know how it goes with hard links. Perhaps the most flexible approach here would be lifecycle hooks where tasks can be attached? |
So I don't understand why If I instead of using boot env's So replacing (deftask backend-test []
(merge-env! :source-paths ["clj/backend/src" "clj/backend/test"]
:resource-paths ["clj/backend/fixtures"])
(test-cljs :js-env :node :exit? true)) with (deftask backend-test []
(merge-env! :source-paths ["clj/backend/src" "clj/backend/test"])
(comp
(with-pre-wrap fileset
(-> fileset
(add-resource (java.io.File. "clj/backend/fixtures"))))
(test-cljs :js-env :node :exit? true)) actually fixes my issue with the currently published I don't understand why though... |
I'm trying to set up a test system where a test case is automatically generated based on test data present in the file system including the expected output. However, I can't figure out how to access those files from within the test runner.
A simplified example:
Directory structure of
clj/backend
:Is it possible to somehow make the contents of
clj/backend/fixtures
accessible from the test runner so I can generate test cases based on the contents oftest-data
?I saw that e.g
node_modules
is manually moved into the tmp dir: https://github.com/crisptrutski/boot-cljs-test/blob/master/src/crisptrutski/boot_cljs_test.clj#L136So I guess I would somehow have to do that with the files I want to use as well?
Thank you in advance!
The text was updated successfully, but these errors were encountered: