Skip to content

Commit

Permalink
test(rustic-babel): Adds paths test for src block (#72)
Browse files Browse the repository at this point in the history
Adds new justfile target: test-one

Run the test via: just test-one rustic-test-babel-block-with-paths
  • Loading branch information
EnigmaCurry authored Jan 7, 2025
1 parent 9fdf5c7 commit e5c0271
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ build:
test:
eask compile
eask emacs --batch -L . -L test -l test/all-tests.el -f ert-run-tests-batch-and-exit

test-one TEST_NAME:
eask compile
eask emacs --batch -L . -L test -l test/all-tests.el -eval '(ert-run-tests-batch-and-exit "{{TEST_NAME}}")'
19 changes: 19 additions & 0 deletions test/rustic-babel-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,23 @@
(rustic-test-babel-execute-block buf)
(should (string-equal (rustic-test-babel-check-results buf) "[[\"A\", \"B\"], [\"C\", \"D\"]]\n")))))

(ert-deftest rustic-test-babel-block-with-paths ()
(let* ((current-test-dir (or (and load-file-name (file-name-directory load-file-name))
(and buffer-file-name (file-name-directory buffer-file-name))
default-directory)) ; Fallback to `default-directory`
(string "use foo;
use bar;
fn main() {
foo::foo();
bar::bar();
}")
(params (format ":paths '((foo . \"%s/test-project/crates/foo\") (bar . \"%s/test-project/crates/bar\")) :crates '((foo . 0.0.1) (bar . 0.0.1))"
(expand-file-name "test" current-test-dir)
(expand-file-name "test" current-test-dir)))
(buf (rustic-test-get-babel-block string params)))
(with-current-buffer buf
(rustic-test-babel-execute-block buf)
(should (eq (rustic-test-babel-check-results buf) nil)))))


(provide 'rustic-babel-test)
10 changes: 9 additions & 1 deletion test/test-project/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/test-project/crates/bar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "bar"
version = "0.0.1"
3 changes: 3 additions & 0 deletions test/test-project/crates/bar/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn bar() {
()
}
3 changes: 3 additions & 0 deletions test/test-project/crates/foo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "foo"
version = "0.0.1"
3 changes: 3 additions & 0 deletions test/test-project/crates/foo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn foo() {
()
}

0 comments on commit e5c0271

Please sign in to comment.