[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 571de3af18: 再次简化 test
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 571de3af18: 再次简化 test |
Date: |
Sat, 25 Dec 2021 02:57:38 -0500 (EST) |
branch: externals/pyim
commit 571de3af1899d1584c09e7d2fbb350d5418efa04
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
再次简化 test
---
.github/workflows/test.yml | 2 +-
.gitignore | 6 ++---
Makefile => tests/Makefile | 7 +++---
tests/pyim-tests.el | 63 ++++++++++++++++++++++++----------------------
4 files changed, 40 insertions(+), 38 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 46babbf81e..438f45f20e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -24,4 +24,4 @@ jobs:
run: emacs --version
- name: Run tests
- run: make test
+ run: make -C tests test
diff --git a/.gitignore b/.gitignore
index 4149ef55d2..99aa775db0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,11 +4,11 @@
/*/*.html
/*/*.*~
/*.patch
-deps/
# Files generated during `make packages/pyim`.
*.elc
/pyim-autoloads.el
/pyim-pkg.el
-/pyim-dcache-*
-/tests/pyim-dcache-*
\ No newline at end of file
+/tests/pyim-tests-dcache-*
+/tests/deps/
+
diff --git a/Makefile b/tests/Makefile
similarity index 86%
rename from Makefile
rename to tests/Makefile
index 36839498d7..13e7966f81 100644
--- a/Makefile
+++ b/tests/Makefile
@@ -3,9 +3,7 @@ SHELL = /bin/sh
EMACS ?= emacs
clean:
- @rm -f *~
- @rm -f \#*\#
- @rm -f *.elc
+ @rm -rf pyim-tests-dcache-*
.PHONY: deps
deps:
@@ -18,4 +16,5 @@ deps:
.PHONY: test
test: deps clean
- @$(EMACS) -batch --quick --directory . --directory ./deps --load
./tests/pyim-tests.el
+ @$(EMACS) --batch --quick --directory .. --directory ./deps --load
./pyim-tests.el
+ @rm -rf pyim-tests-dcache-*
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 6063900b8b..328752770a 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -38,6 +38,9 @@
(setq default-input-method "pyim")
(setq pyim-dicts nil)
(setq pyim-extra-dicts nil)
+;; 设置 pyim-dcache-directory, 防止用户个人词库不小心被覆盖掉。
+(setq pyim-dcache-directory
+ (file-name-as-directory (make-temp-name "pyim-tests-dcache-")))
;; 做测试的时候不保存词库,防止因为误操作导致个人词库损坏。
(defalias 'pyim-kill-emacs-hook-function #'ignore)
@@ -563,39 +566,39 @@
;; ** pyim-import 相关单元测试
(ert-deftest pyim-tests-pyim-import-words-and-counts ()
;; 这个测试目前主要用于手工测试,在 github 上这个测试无法通过的。
- :expected-result :failed
- (let ((pyim-dcache-directory
- (file-name-as-directory (make-temp-name "pyim-dcache-")))
- (file (make-temp-file "pyim-tests-import")))
- ;; 删除测试用词条
- (dolist (x '("测㤅" "测嘊" "测伌"))
- (pyim-process-delete-word x))
- (dolist (x '("测㤅" "测嘊" "测伌"))
- (should-not (member x (pyim-dcache-get "ce-ai" '(icode2word)))))
- (should-not (equal (gethash "测㤅" pyim-dhashcache-iword2count) 76543))
- (should-not (equal (gethash "测嘊" pyim-dhashcache-iword2count) 34567))
- (should-not (equal (gethash "测伌" pyim-dhashcache-iword2count) 0))
-
- ;; 导入测试用词条
- (with-temp-buffer
- (insert
- ";;; -*- coding: utf-8-unix -*-
+ (when (not noninteractive)
+ (let ((pyim-dcache-directory
+ (file-name-as-directory (make-temp-name "pyim-tests-dcache-")))
+ (file (make-temp-file "pyim-tests-import")))
+ ;; 删除测试用词条
+ (dolist (x '("测㤅" "测嘊" "测伌"))
+ (pyim-process-delete-word x))
+ (dolist (x '("测㤅" "测嘊" "测伌"))
+ (should-not (member x (pyim-dcache-get "ce-ai" '(icode2word)))))
+ (should-not (equal (gethash "测㤅" pyim-dhashcache-iword2count) 76543))
+ (should-not (equal (gethash "测嘊" pyim-dhashcache-iword2count) 34567))
+ (should-not (equal (gethash "测伌" pyim-dhashcache-iword2count) 0))
+
+ ;; 导入测试用词条
+ (with-temp-buffer
+ (insert
+ ";;; -*- coding: utf-8-unix -*-
测㤅 76543 ce-ai
测嘊 34567
测伌")
- (write-file file))
- (pyim-import-words-and-counts file (lambda (orig-count new-count)
new-count) t)
+ (write-file file))
+ (pyim-import-words-and-counts file (lambda (orig-count new-count)
new-count) t)
- ;; 测试词条是否存在
- (dolist (x '("测㤅" "测嘊" "测伌"))
- (should (member x (pyim-dcache-get "ce-ai" '(icode2word)))))
- (should (equal (gethash "测㤅" pyim-dhashcache-iword2count) 76543))
- (should (equal (gethash "测嘊" pyim-dhashcache-iword2count) 34567))
- (should (equal (gethash "测伌" pyim-dhashcache-iword2count) 0))))
+ ;; 测试词条是否存在
+ (dolist (x '("测㤅" "测嘊" "测伌"))
+ (should (member x (pyim-dcache-get "ce-ai" '(icode2word)))))
+ (should (equal (gethash "测㤅" pyim-dhashcache-iword2count) 76543))
+ (should (equal (gethash "测嘊" pyim-dhashcache-iword2count) 34567))
+ (should (equal (gethash "测伌" pyim-dhashcache-iword2count) 0)))))
;; ** pyim-dcache 相关单元测试
(ert-deftest pyim-tests-pyim-dcache-save/read-variable-value ()
- (let* ((file (make-temp-file "pyim-dcache-"))
+ (let* ((file (make-temp-file "pyim-tests-dcache-"))
(backup-file (concat file "-backup-" (format-time-string
"%Y%m%d%H%M%S")))
(value (make-hash-table :test #'equal)))
(puthash "ni-hao" (list "你好") value)
@@ -610,7 +613,7 @@
(ert-deftest pyim-tests-pyim-dcache-handle-variable ()
(let ((pyim-dcache-directory
- (file-name-as-directory (make-temp-name "pyim-dcache-")))
+ (file-name-as-directory (make-temp-name "pyim-tests-dcache-")))
my/test:1)
(pyim-dcache-save-variable 'my/test:1 "hello")
@@ -631,7 +634,7 @@
(ert-deftest pyim-tests-pyim-dcache-export ()
(let ((pyim-dhashcache-iword2count (make-hash-table :test #'equal))
(pyim-dhashcache-icode2word (make-hash-table :test #'equal))
- (file (make-temp-file "pyim-dcache-export-")))
+ (file (make-temp-file "pyim-tests-dcache-export-")))
(puthash "你好" 10 pyim-dhashcache-iword2count)
(puthash "尼耗" 1 pyim-dhashcache-iword2count)
(puthash "ni-hao" (list "你好" "尼耗") pyim-dhashcache-icode2word)
@@ -673,7 +676,7 @@ ni-hao 你好 尼耗
(ert-deftest pyim-tests-pyim-dhashcache-generate-file ()
(let ((dist-file (make-temp-file "pyim-dist-"))
- (dcache-file (make-temp-file "pyim-dcache-"))
+ (dcache-file (make-temp-file "pyim-tests-dcache-"))
(word2code-dcache-file (make-temp-file "pyim-word2code-dcache-"))
output1 output2)
(with-temp-buffer
@@ -772,7 +775,7 @@ zuo-zuo-you-mang 作作有芒")
(should (equal (gethash "你好" pyim-dhashcache-iword2count) 20))))
(ert-deftest pyim-tests-pyim-dhashcache-export ()
- (let ((file (make-temp-file "pyim-dcache-"))
+ (let ((file (make-temp-file "pyim-tests-dcache-"))
(icode2word (make-hash-table :test #'equal)))
(puthash "yin-xing"
(list (propertize "银行" :noexport t)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/pyim 571de3af18: 再次简化 test,
ELPA Syncer <=