|
| 1 | +;;; go-compile-test.el --- unit tests for ‘go-mode’ compilation -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright 2020 Google LLC |
| 4 | +;; |
| 5 | +;; Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +;; you may not use this file except in compliance with the License. |
| 7 | +;; You may obtain a copy of the License at |
| 8 | +;; |
| 9 | +;; https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +;; |
| 11 | +;; Unless required by applicable law or agreed to in writing, software |
| 12 | +;; distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +;; See the License for the specific language governing permissions and |
| 15 | +;; limitations under the License. |
| 16 | + |
| 17 | +;;; Commentary: |
| 18 | + |
| 19 | +;; Unit tests for the ‘compilation-mode’ integration of ‘go-mode’. |
| 20 | + |
| 21 | +;;; Code: |
| 22 | + |
| 23 | +(require 'go-mode) |
| 24 | + |
| 25 | +(require 'cl-lib) |
| 26 | +(require 'ert) |
| 27 | + |
| 28 | +(ert-deftest go-greedy-test-pattern () |
| 29 | + "Verify that https://github.com/dominikh/go-mode.el/issues/361 is fixed." |
| 30 | + ;; ‘compilation-mode’ doesn’t have its own syntax table, so we use the |
| 31 | + ;; standard one. |
| 32 | + (with-temp-buffer (go-mode)) ; initialize once |
| 33 | + (with-syntax-table (standard-syntax-table) |
| 34 | + (should-not (string-match-p |
| 35 | + (cadr (assq 'go-test compilation-error-regexp-alist-alist)) |
| 36 | + "\nfile.go:1:2: word word")))) |
| 37 | + |
| 38 | +(ert-deftest go-1.14-test-v () |
| 39 | + "Verify that https://github.com/dominikh/go-mode.el/issues/362 is fixed." |
| 40 | + (with-temp-buffer (go-mode)) ; initialize once |
| 41 | + (with-syntax-table (standard-syntax-table) |
| 42 | + (cl-destructuring-bind (regexp file line) |
| 43 | + (cdr (assq 'go-test compilation-error-regexp-alist-alist)) |
| 44 | + (let ((text " Test: foo_test.go:6: message")) |
| 45 | + (should (string-match regexp text)) |
| 46 | + (should (equal (match-string file text) "foo_test.go")) |
| 47 | + (should (equal (match-string line text) "6")))))) |
| 48 | + |
| 49 | +;;; go-compile-test.el ends here |
0 commit comments