From 671a99d516010e54c3fb82c2d9fd4ad442a775ff Mon Sep 17 00:00:00 2001 From: Chris Rink Date: Mon, 25 Nov 2024 11:03:04 -0500 Subject: [PATCH] Light testing --- docs/api/process.rst | 3 ++- src/basilisp/process.lpy | 5 ++--- tests/basilisp/test_process.lpy | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/basilisp/test_process.lpy diff --git a/docs/api/process.rst b/docs/api/process.rst index db05619f..7efb2611 100644 --- a/docs/api/process.rst +++ b/docs/api/process.rst @@ -7,4 +7,5 @@ basilisp.process .. autonamespace:: basilisp.process :members: - :undoc-members: \ No newline at end of file + :undoc-members: + :exclude-members: FileWrapper, SubprocessRedirectable, ->FileWrapper, is-file-like?, is-path-like? \ No newline at end of file diff --git a/src/basilisp/process.lpy b/src/basilisp/process.lpy index d27f7403..d6ff724a 100644 --- a/src/basilisp/process.lpy +++ b/src/basilisp/process.lpy @@ -232,8 +232,7 @@ (defn exec "Execute a command as by :lpy:fn:`start` and, upon successful return, return the - captured value of the process ``stdout`` (which may be a string or bytes depending - on whether the process was opened in text or binary mode). + captured value of the process ``stdout`` as by :lpy:fn:`basilisp.core/slurp`. If ``opts`` are specified, they should be provided as a map in the first argument position. ``opts`` are exactly the same as those in :lpy:fn:`start`. @@ -293,7 +292,7 @@ The following keyword/value arguments are optional: :keyword ``:input``: a string or bytes object (depending on whether the process - was opened in text or bniary mode); if omitted, do not send anything + was opened in text or binary mode); if omitted, do not send anything :keyword ``timeout``: an optional timeout" [process & kwargs] (let [kwargs (apply hash-map kwargs)] diff --git a/tests/basilisp/test_process.lpy b/tests/basilisp/test_process.lpy new file mode 100644 index 00000000..c947bd21 --- /dev/null +++ b/tests/basilisp/test_process.lpy @@ -0,0 +1,37 @@ +(ns tests.basilisp.test-process + (:import pathlib) + (:require + [basilisp.process :as process] + [basilisp.test :as test :refer [deftest is are testing]] + [basilisp.test.fixtures :as fixtures :refer [*tempdir*]])) + +(test/use-fixtures :each fixtures/tempdir) + +(deftest is-file-like?-test + (are [v] (true? (process/is-file-like? v)) + -1 + 0 + 1) + + (with-open [f (python/open (pathlib/Path *tempdir* "is-file-like.txt") ** :mode "w")] + (is (true? (process/is-file-like? f)))) + + (are [v] (false? (process/is-file-like? v)) + "i'm a path-like" + #b "i'm a path-like" + (pathlib/Path "/home/chris"))) + +(deftest is-path-like?-test + (are [v] (true? (process/is-path-like? v)) + "i'm a path-like" + #b "i'm a path-like" + (pathlib/Path "/home/chris")) + + (with-open [f (python/open (pathlib/Path *tempdir* "is-path-like.txt") ** :mode "w")] + (is (false? (process/is-path-like? f)))) + + (are [v] (false? (process/is-path-like? v)) + nil + 32 + 32.1 + (python/object)))