[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 374835c 355/385: a test for interactive c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 374835c 355/385: a test for interactive commands |
Date: |
Wed, 6 Oct 2021 00:00:03 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 374835c822a31a3c574d0cd3208951f1c4c58501
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
a test for interactive commands
---
haskell-tng-hsinspect.el | 17 ++++++----
test/haskell-tng-dynamic-test.el | 44 +++++++++++++++++++++++++
test/haskell-tng-hsinspect-test.el | 2 --
test/src/hsinspect.hs | 6 ++--
test/src/{hsinspect.hs => hsinspect.hs.dynamic} | 6 ++--
5 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index 2855132..a44f422 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -431,14 +431,17 @@ Does not persist the cache changes to disk."
(append haskell-tng--hsinspect-imports updates))))
;; TODO add a package-wide variable cache
+(defvar-local haskell-tng--hsinspect-index nil)
(defun haskell-tng--hsinspect-index (&optional flush-cache)
- (when-let (ghcflags-dir
- (locate-dominating-file default-directory ".ghc.flags"))
- (haskell-tng--util-cached-disk
- (lambda () (haskell-tng--hsinspect flush-cache "index"))
- (concat "hsinspect-0.0.7" (expand-file-name ghcflags-dir) "index")
- nil
- flush-cache)))
+ (or ;; this variable cache is only used in tests
+ haskell-tng--hsinspect-index
+ (when-let (ghcflags-dir
+ (locate-dominating-file default-directory ".ghc.flags"))
+ (haskell-tng--util-cached-disk
+ (lambda () (haskell-tng--hsinspect flush-cache "index"))
+ (concat "hsinspect-0.0.7" (expand-file-name ghcflags-dir) "index")
+ nil
+ flush-cache))))
;; TODO add a project-wide variable cache
(defun haskell-tng--hsinspect-exe (&optional flush-cache)
diff --git a/test/haskell-tng-dynamic-test.el b/test/haskell-tng-dynamic-test.el
new file mode 100644
index 0000000..8da74d3
--- /dev/null
+++ b/test/haskell-tng-dynamic-test.el
@@ -0,0 +1,44 @@
+;;; haskell-tng-dynamic-test.el --- tests that run dynamic commands -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2020 Tseen She
+;; License: GPL 3 or any later version
+
+;;; Commentary:
+;;
+;; These tests load a user-file and search for comments containing dynamic
+;; interactive commands, simulating user input, which are then compared to a
+;; file on disk containing the expected output.
+;;
+;;; Code:
+
+(require 'ert)
+(require 's)
+
+(require 'haskell-tng-mode)
+
+(require 'haskell-tng-testutils
+ "test/haskell-tng-testutils.el")
+
+(ert-deftest haskell-tng-dynamic-file-tests ()
+ (should (have-expected-dynamic-output (testdata "src/hsinspect.hs"))))
+
+(defun have-expected-dynamic-output (file)
+ (haskell-tng--testutils-assert-file-contents
+ file
+ #'haskell-tng-mode
+ #'haskell-tng-dynamic-test-to-string
+ "dynamic"))
+
+(defun haskell-tng-dynamic-test-to-string ()
+ (goto-char (point-min))
+
+ (while (re-search-forward (rx word-start "RUN" word-end) nil t)
+ (when (is-comment-at-point)
+ (let ((start (point))
+ (command (read (current-buffer))))
+ (eval command)
+ (goto-char start))))
+ (buffer-substring-no-properties (point-min) (point-max)))
+
+(provide 'haskell-tng-dynamic-test)
+;;; haskell-tng-dynamic-test.el ends here
diff --git a/test/haskell-tng-hsinspect-test.el
b/test/haskell-tng-hsinspect-test.el
index a4653f6..9a17cda 100644
--- a/test/haskell-tng-hsinspect-test.el
+++ b/test/haskell-tng-hsinspect-test.el
@@ -11,8 +11,6 @@
(require 'haskell-tng-testutils
"test/haskell-tng-testutils.el")
-;; TODO tests of the user facing functions in the golden data format
-
(ert-deftest haskell-tng-hsinspect-test-qualify-latest ()
(let ((imports
(haskell-tng--util-read
diff --git a/test/src/hsinspect.hs b/test/src/hsinspect.hs
index 39631a1..906f760 100644
--- a/test/src/hsinspect.hs
+++ b/test/src/hsinspect.hs
@@ -1,11 +1,13 @@
--- IMPORTS "../data/hsinspect-0.0.8-imports.sexp.gz"
--- INDEX "../data/hsinspect-0.0.9-index.sexp.gz"
+-- RUN (setq haskell-tng--hsinspect-imports (haskell-tng--util-read
"test/data/hsinspect-0.0.8-imports.sexp.gz"))
+--
+-- RUN (setq haskell-tng--hsinspect-index (haskell-tng--util-read
"test/data/hsinspect-0.0.9-index.sexp.gz"))
module Medley.Wibble where
import Data.Functor.Contravariant as C
import Medley.Wobble
import Prelude (zip)
+-- FIXME commands
-- COMPLETE 11
foo = C.pha
diff --git a/test/src/hsinspect.hs b/test/src/hsinspect.hs.dynamic
similarity index 63%
copy from test/src/hsinspect.hs
copy to test/src/hsinspect.hs.dynamic
index 39631a1..906f760 100644
--- a/test/src/hsinspect.hs
+++ b/test/src/hsinspect.hs.dynamic
@@ -1,11 +1,13 @@
--- IMPORTS "../data/hsinspect-0.0.8-imports.sexp.gz"
--- INDEX "../data/hsinspect-0.0.9-index.sexp.gz"
+-- RUN (setq haskell-tng--hsinspect-imports (haskell-tng--util-read
"test/data/hsinspect-0.0.8-imports.sexp.gz"))
+--
+-- RUN (setq haskell-tng--hsinspect-index (haskell-tng--util-read
"test/data/hsinspect-0.0.9-index.sexp.gz"))
module Medley.Wibble where
import Data.Functor.Contravariant as C
import Medley.Wobble
import Prelude (zip)
+-- FIXME commands
-- COMPLETE 11
foo = C.pha
- [nongnu] elpa/haskell-tng-mode f7e8040 213/385: = ends a type sig, (continued)
- [nongnu] elpa/haskell-tng-mode f7e8040 213/385: = ends a type sig, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fe9d65d 222/385: helper for yatemplates, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bc93c3d 224/385: very alpha hsinspect support, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 658ddb6 251/385: docs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 73a60f5 309/385: cache `which hsinspect` per project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provided PATH, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b1c664b 364/385: allow hsinspect population in the background, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ce17d96 376/385: new hsinspect release, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode eb6b487 357/385: test fqn-at-point and fix a longstanding bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 103e758 325/385: expose some more hsinspect-0.0.8 index info, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 374835c 355/385: a test for interactive commands,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode e3c6dc6 336/385: follow re-exports, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9904e72 366/385: jump-to-definition works inside the project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1c68e79 381/385: requires emacs 27, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 55d8e69 385/385: upgrade hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 97e4a66 379/385: bump hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3870bf1 367/385: time to remove the cabal v2- prefixes, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 47f1f9f 180/385: lex CONSYM correctly, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9bc086a 187/385: easier install, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4f40db3 218/385: fast-tags is stack compatible by default, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 59640ce 234/385: cleanups thanks to MELPA review, ELPA Syncer, 2021/10/06