Skip to content

Commit e5c0271

Browse files
authored
test(rustic-babel): Adds paths test for src block (#72)
Adds new justfile target: test-one Run the test via: just test-one rustic-test-babel-block-with-paths
1 parent 9fdf5c7 commit e5c0271

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ build:
1212
test:
1313
eask compile
1414
eask emacs --batch -L . -L test -l test/all-tests.el -f ert-run-tests-batch-and-exit
15+
16+
test-one TEST_NAME:
17+
eask compile
18+
eask emacs --batch -L . -L test -l test/all-tests.el -eval '(ert-run-tests-batch-and-exit "{{TEST_NAME}}")'

test/rustic-babel-test.el

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,23 @@
295295
(rustic-test-babel-execute-block buf)
296296
(should (string-equal (rustic-test-babel-check-results buf) "[[\"A\", \"B\"], [\"C\", \"D\"]]\n")))))
297297

298+
(ert-deftest rustic-test-babel-block-with-paths ()
299+
(let* ((current-test-dir (or (and load-file-name (file-name-directory load-file-name))
300+
(and buffer-file-name (file-name-directory buffer-file-name))
301+
default-directory)) ; Fallback to `default-directory`
302+
(string "use foo;
303+
use bar;
304+
fn main() {
305+
foo::foo();
306+
bar::bar();
307+
}")
308+
(params (format ":paths '((foo . \"%s/test-project/crates/foo\") (bar . \"%s/test-project/crates/bar\")) :crates '((foo . 0.0.1) (bar . 0.0.1))"
309+
(expand-file-name "test" current-test-dir)
310+
(expand-file-name "test" current-test-dir)))
311+
(buf (rustic-test-get-babel-block string params)))
312+
(with-current-buffer buf
313+
(rustic-test-babel-execute-block buf)
314+
(should (eq (rustic-test-babel-check-results buf) nil)))))
315+
316+
298317
(provide 'rustic-babel-test)

test/test-project/Cargo.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "bar"
3+
version = "0.0.1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn bar() {
2+
()
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "foo"
3+
version = "0.0.1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn foo() {
2+
()
3+
}

0 commit comments

Comments
 (0)