Skip to content

Commit 0931e0f

Browse files
committed
Add integration test.
To make sure that yapfify works with the most recent version of yapf. Run this test against the master branch.
1 parent 756ebae commit 0931e0f

9 files changed

+50
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.cask

Cask

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(source gnu)
2+
(source melpa)
3+
4+
(package-file "yapfify.el")
5+
6+
(development
7+
(depends-on "f")
8+
(depends-on "ert-runner"))

README.org

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[[https://circleci.com/gh/JorisE/yapfify][https://circleci.com/gh/JorisE/yapfify.svg?style=svg]]
2+
3+
14
* Yapfify
25
Yapfify uses yapf to format a Python buffer. It can be called explicitly on a
36
certain buffer, but more conveniently, a minor-mode 'yapf-mode' is provided

circle.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
pre:
3+
- sudo apt-get update; sudo apt-get install emacs
4+
- sudo pip install -U git+http://github.com/google/yapf
5+
- curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python
6+
7+
test:
8+
pre:
9+
- PATH="/home/ubuntu/.cask:$PATH"./run_tests.sh

run_tests.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# run_tests.sh is used only to get the DATA_DIR. It feels like there should be a
4+
# better way to do this.
5+
DATA_DIR=$(pwd)/test/data/ cask exec ert-runner -l yapfify.el

test/data/.style.yapf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[style]
2+
indent_width=2

test/data/formatted.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
3+
4+
def function():
5+
x = 2

test/data/unformatted.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
def function():
4+
x = 2

test/yapfify-test.el

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(ert-deftest test-yapfify-buffers ()
2+
"Test that yapfiffy reformats a buffer using the settings in .style.yapf"
3+
(let* ((datadir (getenv "DATA_DIR"))
4+
(unformatted (f-join datadir "unformatted.py"))
5+
(formatted (f-join datadir "formatted.py")))
6+
(find-file unformatted)
7+
;; When yapf is called on the unformatted buffer, yapf should exit with status code 1.
8+
(should (eq (call-process-region (point-min) (point-max) "diff" nil nil nil formatted "-") 1))
9+
(yapfify-buffer)
10+
;; After yapfify-buffer is used, yapf should exit with exit code 0.
11+
(should (eq (call-process-region (point-min) (point-max) "diff" nil nil nil formatted "-") 0))
12+
)
13+
)

0 commit comments

Comments
 (0)