Skip to content

Commit d974e00

Browse files
committed
Fine-tune github acion tests
1 parent 26b4ace commit d974e00

10 files changed

+55
-64
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Run Emacs tests
7070
uses: nick-invision/retry@v2
7171
with:
72-
timeout_minutes: 5
72+
timeout_minutes: 10
7373
max_attempts: 3
7474
command: cask install ; PYTHONPATH="`pwd`" cask exec ert-runner --reporter ert+duration
7575
- name: Run Python tests

elpy-rpc.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ binaries used to create the virtualenv."
418418
"-m" "pip" "install" "--upgrade"
419419
(elpy-rpc--get-package-list))
420420
0)
421-
(message "Elpy failed to install some of the RPC dependencies, please use `elpy-config' to install them.\n%s" (buffer-substring))
421+
(message "Elpy failed to install some of the RPC dependencies, please use `elpy-config' to install them.\n%s" (buffer-string))
422422
))
423423
(message "Some of Elpy's functionnalities will not work, please use `elpy-config' to install the needed python dependencies.")))
424424

test/elpy-black-fix-code-test.el

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
(if (boundp '*elpy-black-fix-code--black-supported*)
33
*elpy-black-fix-code--black-supported*
44
(setq *elpy-black-fix-code--black-supported*
5-
(not (string< (or (getenv "TRAVIS_PYTHON_VERSION")
6-
(with-temp-buffer
7-
(call-process elpy-rpc-python-command
8-
nil '(t t) nil "--version")
9-
(goto-char (point-min))
10-
(re-search-forward "\\([0-9.]+\\)" nil t)
11-
(or (match-string 1) "")))
12-
"3.6")))))
5+
(not (string< (elpy-get-python-version) "3.6")))))
136

147
(when (elpy-black-fix-code--black-supported)
158
(ert-deftest elpy-black-fix-code-should-retain-line-and-column ()
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
;; This randomly breaks on Travis for some reason I have not yet
2-
;; understood.
3-
4-
;; (ert-deftest elpy-open-and-indent-line-below ()
5-
;; (elpy-testcase ()
6-
;; (elpy-enable)
7-
;; (python-mode)
8-
;; (insert-source
9-
;; "def foo():"
10-
;; " x = 5")
11-
;; (goto-char (point-min))
12-
;; (re-search-forward "x")
13-
;; (elpy-open-and-indent-line-above)
14-
;; (should (equal (buffer-string)
15-
;; "def foo():\n \n x = 5\n"))
16-
;; (should (looking-at "\n x = 5"))))
1+
(ert-deftest elpy-open-and-indent-line-below ()
2+
(elpy-testcase ()
3+
(elpy-enable)
4+
(python-mode)
5+
(insert-source
6+
"def foo():"
7+
" x = 5")
8+
(goto-char (point-min))
9+
(re-search-forward "x")
10+
(elpy-open-and-indent-line-above)
11+
(should (equal (buffer-string)
12+
"def foo():\n \n x = 5\n"))
13+
(should (looking-at "\n x = 5"))))
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
;; This randomly breaks on Travis for some reason I have not yet
2-
;; understood.
3-
4-
;; (ert-deftest elpy-open-and-indent-line-below ()
5-
;; (elpy-testcase ()
6-
;; (elpy-enable)
7-
;; (python-mode)
8-
;; (insert "def foo():\n")
9-
;; (goto-char 2)
10-
;; (elpy-open-and-indent-line-below)
11-
;; (should (or (equal (buffer-string)
12-
;; "def foo():\n \n")
13-
;; (equal (buffer-string)
14-
;; "def foo():\n\n")))
15-
;; (should (equal (point) (- (point-max)
16-
;; 1)))))
1+
(ert-deftest elpy-open-and-indent-line-below ()
2+
(elpy-testcase ()
3+
(elpy-enable)
4+
(python-mode)
5+
(insert "def foo():\n")
6+
(goto-char 2)
7+
(elpy-open-and-indent-line-below)
8+
(should (or (equal (buffer-string)
9+
"def foo():\n \n")
10+
(equal (buffer-string)
11+
"def foo():\n\n")))
12+
(should (equal (point) (- (point-max)
13+
1)))))

test/elpy-xref--apropos-test.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(insert "def foo(x, y):\n"
88
" return x + y\n"
99
"var1 = foo(5, 2)")
10+
(save-buffer)
1011
(let ((xref-items (elpy-xref--apropos "fo"))
1112
(basefile (f-join project-root "test.py")))
1213

test/elpy-xref--definitions-test.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(insert "def foo(x, y):\n"
88
" return x + y\n"
99
"var1 = foo(5, 2)")
10+
(save-buffer)
1011
(let* ((basefile (f-join project-root "test.py"))
1112
(foo-defs (car (elpy-xref--definitions "1: foo")))
1213
(summary (xref-item-summary foo-defs))

test/elpy-xref--get-completion-table-test.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
(insert "def foo(x, y):\n"
77
" return x + y\n"
88
"var1 = foo(5, 2)")
9+
(save-buffer)
910
(let ((identifiers (elpy-xref--get-completion-table)))
1011
(should (equal identifiers
1112
(list "3: foo" "3: var1" "2: y" "2: x" "1: y" "1: x" "1: foo")))))))

test/elpy-yapf-fix-code-test.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ert-deftest elpy-yapf-fix-code-should-retain-line-and-column ()
2-
(let* ((pyversion (getenv "TRAVIS_PYTHON_VERSION"))
2+
(let* ((pyversion (elpy-get-python-version))
33
(yapf-not-supported (or (string< pyversion "2.7")
44
(and (not (string< pyversion "3.0"))
55
(string< pyversion "3.4")))))
@@ -17,7 +17,7 @@
1717
"y = 2_|_"))))))
1818

1919
(ert-deftest elpy-yapf-fix-code-in-region-should-retain-line-and-column ()
20-
(let* ((pyversion (getenv "TRAVIS_PYTHON_VERSION"))
20+
(let* ((pyversion (elpy-get-python-version))
2121
(yapf-not-supported (or (string< pyversion "2.7")
2222
(and (not (string< pyversion "3.0"))
2323
(string< pyversion "3.4")))))
@@ -41,7 +41,7 @@
4141
))))))
4242

4343
(ert-deftest elpy-yapf-fix-code-should-throw-error-for-invalid-code ()
44-
(let* ((pyversion (getenv "TRAVIS_PYTHON_VERSION"))
44+
(let* ((pyversion (elpy-get-python-version))
4545
(yapf-not-supported (or (string< pyversion "2.7")
4646
(and (not (string< pyversion "3.0"))
4747
(string< pyversion "3.4")))))

test/test-helper.el

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,19 @@
2020

2121

2222
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23-
;; Travis
23+
;; CI
2424
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25-
;; Travis is using virtualenvs to test specific version of python
26-
;; we need to use it as the system environment
27-
(advice-add 'elpy-rpc-get-virtualenv-path
28-
:around (lambda (fun &rest args)
29-
(if (and (getenv "TRAVIS")
30-
(or (eq elpy-rpc-virtualenv-path 'global) ;; for backward compatibility
31-
(eq elpy-rpc-virtualenv-path 'system)))
32-
(expand-file-name
33-
(concat
34-
"~/virtualenv/"
35-
"python"
36-
(getenv "TRAVIS_PYTHON_VERSION")))
37-
(apply fun args))))
38-
39-
;; Travis regularly has some lag for some reason.
40-
(setq elpy-rpc-timeout 10)
41-
;; Print elpy configuration
42-
(when (getenv "TRAVIS")
25+
(when (getenv "GITHUB_RUN_ID")
26+
;; Make sure we use the proper python version to create the virtualenv
27+
;; This is necessary as multiple python binaries will be present on
28+
;; the virtual machine
29+
(advice-add 'elpy-rpc--create-virtualenv
30+
:around (lambda (orig-fun &rest args)
31+
(let ((elpy-rpc-python-command (executable-find "python")))
32+
(apply orig-fun args))))
33+
;; CI regularly has some lag for some reason.
34+
(setq elpy-rpc-timeout 10)
35+
;; Print elpy configuration
4336
(elpy-config)
4437
(with-current-buffer "*Elpy Config*"
4538
(message (buffer-substring-no-properties (point-min) (point-max)))))
@@ -61,6 +54,14 @@
6154
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6255
;; Test helper
6356
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
57+
(defun elpy-get-python-version ()
58+
(with-temp-buffer
59+
(call-process elpy-rpc-python-command
60+
nil '(t t) nil "--version")
61+
(goto-char (point-min))
62+
(re-search-forward "\\([0-9.]+\\)" nil t)
63+
(or (match-string 1) "")))
64+
6465
(defmacro mletf* (bindings &rest body)
6566
"Liket `cl-letf*', just with a slightly more concise function syntax.
6667

0 commit comments

Comments
 (0)