Skip to content

Commit

Permalink
Light testing
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisrink10 committed Nov 25, 2024
1 parent 5f9fde2 commit 671a99d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/api/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ basilisp.process

.. autonamespace:: basilisp.process
:members:
:undoc-members:
:undoc-members:
:exclude-members: FileWrapper, SubprocessRedirectable, ->FileWrapper, is-file-like?, is-path-like?
5 changes: 2 additions & 3 deletions src/basilisp/process.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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)]
Expand Down
37 changes: 37 additions & 0 deletions tests/basilisp/test_process.lpy
Original file line number Diff line number Diff line change
@@ -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)))

0 comments on commit 671a99d

Please sign in to comment.