1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341
|
;;; flycheck-test.el --- Flycheck: Unit test suite -*- lexical-binding: t; -*-
;; Copyright (C) 2017 Flycheck contributors
;; Copyright (C) 2013-2016 Sebastian Wiesner and Flycheck contributors
;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; Maintainer: Clément Pit-Claudel <clement.pitclaudel@live.com>
;; fmdkdd <fmdkdd@gmail.com>
;; URL: https://github.com/flycheck/flycheck
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Unit test suite of Flycheck
;; Please keep test cases in the same order as the corresponding definition in
;; flycheck.
;;; Tags
;; For new tests, please add the the section tag. Additionally, add any of the
;; following tags, if appropriate:
;;
;; - `external-tool' for tests which need external tools
;; - `language-LANG' for tests for the language LANG
;;; Code:
;;; Requirements
(require 'dash)
(require 'cl-lib)
(require 'ert) ; Unit test library
(require 'shut-up) ; Silence Emacs and intercept `message'
(require 'flycheck)
(require 'flycheck-ert)
;; Make a best effort to make Coq Mode available
;; (mapc (lambda (dir)
;; (add-to-list 'load-path (expand-file-name "coq/" dir)))
;; '("/usr/share/emacs/site-lisp/"
;; "/usr/local/share/emacs/site-lisp/"))
(add-to-list 'load-path "/usr/share/emacs/site-lisp/")
(autoload 'coq-mode "gallina")
;; Load ESS for R-mode (its autoloads are broken)
(require 'ess-site nil 'noerror)
;;; Directories
(defconst flycheck-test-directory
(file-name-directory (flycheck-current-load-file))
"The test directory.")
(defconst flycheck-test-resources-directory
(expand-file-name "resources/" flycheck-test-directory)
"Directory of test resources.")
(defconst flycheck-test-source-directory
(file-name-directory (directory-file-name flycheck-test-directory))
"The source directory.")
;;; Customization
(ert-deftest flycheck-checkers/there-are-registered-checkers ()
:tags '(customization)
(should flycheck-checkers))
(ert-deftest flycheck-checkers/all-registered-checkers-are-declared ()
:tags '(customization)
(dolist (checker flycheck-checkers)
(should (flycheck-valid-checker-p checker))
(should (flycheck-registered-checker-p checker))))
(ert-deftest flycheck-checkers/all-declared-checkers-are-registered ()
:tags '(customization)
(let ((declared-checkers (flycheck-defined-checkers)))
(should declared-checkers)
(dolist (checker declared-checkers)
(should (memq checker flycheck-checkers))
(should (flycheck-registered-checker-p checker)))))
(ert-deftest flycheck-checkers/no-registered-checker-is-disabled ()
:tags '(customization)
(dolist (checker flycheck-checkers)
(should-not (flycheck-disabled-checker-p checker))))
(ert-deftest flycheck-disabled-checkers/is-empty ()
:tags '(customization)
(should-not (default-value 'flycheck-disabled-checkers)))
(ert-deftest flycheck-locate-config-file-functions/default ()
:tags '(customization)
(should (equal flycheck-locate-config-file-functions
'(flycheck-locate-config-file-by-path
flycheck-locate-config-file-ancestor-directories
flycheck-locate-config-file-home))))
(ert-deftest flycheck-process-error-functions/defaults-to-add-overlay ()
:tags '(customization)
(should (equal flycheck-process-error-functions '(flycheck-add-overlay))))
(ert-deftest flycheck-display-errors-delay/defaults-to-0.9 ()
:tags '(customization)
(should (equal flycheck-display-errors-delay 0.9)))
(ert-deftest flycheck-display-errors-function/defaults-to-display-error-messages ()
:tags '(customization)
(should (eq flycheck-display-errors-function
#'flycheck-display-error-messages)))
(ert-deftest flycheck-indication-mode/defaults-to-left-fringe ()
:tags '(customization)
(should (eq flycheck-indication-mode 'left-fringe)))
(ert-deftest flycheck-highlighting-mode/defaults-to-symbols ()
:tags '(customization)
(should (eq flycheck-highlighting-mode 'symbols)))
(ert-deftest flycheck-check-syntax-automatically/defaults-to-all-events ()
:tags '(customization)
(should (equal flycheck-check-syntax-automatically
'(save idle-change new-line mode-enabled))))
(ert-deftest flycheck-idle-change-delay/defaults-to-0.5 ()
:tags '(customization)
(should (equal flycheck-idle-change-delay 0.5)))
(ert-deftest flycheck-standard-error-navigation/default-to-t ()
:tags '(customization)
(should (eq flycheck-standard-error-navigation t)))
(ert-deftest flycheck-CHECKER-executable/is-special-variable ()
:tags '(customization)
(dolist (checker flycheck-checkers)
(let ((variable (flycheck-checker-executable-variable checker)))
(should (custom-variable-p variable)))))
(ert-deftest flycheck-CHECKER-executable/is-customizable ()
:tags '(customization)
(dolist (checker flycheck-checkers)
(let ((variable (flycheck-checker-executable-variable checker)))
(should (custom-variable-p variable)))))
(ert-deftest flycheck-CHECKER-executable/defaults-to-nil ()
:tags '(customization)
(dolist (checker flycheck-checkers)
(let ((variable (flycheck-checker-executable-variable checker)))
(should (null (symbol-value variable))))))
(ert-deftest flycheck-keymap-prefix/customize-variable-will-modify-keymap ()
:tags '(customization)
(unwind-protect
(progn
(custom-set-variables '(flycheck-keymap-prefix (kbd "C-c e")))
(should (eq 'flycheck-next-error
(lookup-key flycheck-mode-map (kbd "C-c e n")))))
(ignore-errors
(custom-set-variables '(flycheck-keymap-prefix (kbd "C-c !"))))))
(ert-deftest flycheck-temp-prefix/default ()
:tags '(customization)
(should (equal flycheck-temp-prefix "flycheck")))
;;; Utility functions
(ert-deftest flycheck-string-to-number-safe/nil ()
:tags '(utility)
(should-not (flycheck-string-to-number-safe nil)))
(ert-deftest flycheck-string-to-number-safe/not-a-string ()
:tags '(utility)
(should-not (flycheck-string-to-number-safe [1 2 3])))
(ert-deftest flycheck-string-to-number-safe/already-a-number ()
:tags '(utility)
(should-not (flycheck-string-to-number-safe 3)))
(ert-deftest flycheck-string-to-number-safe/a-non-numeric-string ()
:tags '(utility)
(should-not (flycheck-string-to-number-safe "123helloworld")))
(ert-deftest flycheck-string-to-number-safe/a-numeric-string ()
:tags '(utility)
(should (= (flycheck-string-to-number-safe "123") 123)))
(ert-deftest flycheck-string-to-number-safe/a-numeric-string-with-leading-whitespace ()
:tags '(utility)
(should-not (flycheck-string-to-number-safe " 123")))
(ert-deftest flycheck-string-to-number-safe/a-numeric-string-with-trailing-whitespace ()
:tags '(utility)
(should-not (flycheck-string-to-number-safe "123 ")))
(ert-deftest flycheck-string-list-p/not-a-list ()
:tags '(utility)
(should-not (flycheck-string-list-p ["foo" "bar"])))
(ert-deftest flycheck-string-list-p/a-plain-string ()
:tags '(utility)
(should-not (flycheck-string-list-p "foo")))
(ert-deftest flycheck-string-list-p/a-plain-integer ()
:tags '(utility)
(should-not (flycheck-string-list-p 1)))
(ert-deftest flycheck-string-list-p/a-plain-symbol ()
:tags '(utility)
(should-not (flycheck-string-list-p 'foo)))
(ert-deftest flycheck-string-list-p/a-list-with-mixed-types ()
:tags '(utility)
(should-not (flycheck-string-list-p '("foo" 1 test))))
(ert-deftest flycheck-string-list-p/a-list-of-symbols ()
:tags '(utility)
(should-not (flycheck-string-list-p '(foo bar))))
(ert-deftest flycheck-string-list-p/a-list-of-strings ()
:tags '(utility)
(should (flycheck-string-list-p '("foo" "bar"))))
(ert-deftest flycheck-string-list-p/an-empty-list ()
:tags '(utility)
(should (flycheck-string-list-p '())))
(ert-deftest flycheck-symbol-list-p/not-a-list ()
:tags '(utility)
(should-not (flycheck-symbol-list-p ["foo" "bar"])))
(ert-deftest flycheck-symbol-list-p/a-plain-string ()
:tags '(utility)
(should-not (flycheck-symbol-list-p "foo")))
(ert-deftest flycheck-symbol-list-p/a-plain-integer ()
:tags '(utility)
(should-not (flycheck-symbol-list-p 1)))
(ert-deftest flycheck-symbol-list-p/a-plain-symbol ()
:tags '(utility)
(should-not (flycheck-symbol-list-p 'foo)))
(ert-deftest flycheck-symbol-list-p/a-list-with-mixed-types ()
:tags '(utility)
(should-not (flycheck-symbol-list-p '("foo" 1 test))))
(ert-deftest flycheck-symbol-list-p/a-list-of-strings ()
:tags '(utility)
(should-not (flycheck-symbol-list-p '("foo" "bar"))))
(ert-deftest flycheck-symbol-list-p/a-list-of-symbols ()
:tags '(utility)
(should (flycheck-symbol-list-p '(foo bar))))
(ert-deftest flycheck-symbol-list-p/an-empty-list ()
:tags '(utility)
(should (flycheck-symbol-list-p '())))
(ert-deftest flycheck-same-files-p/same-files ()
:tags '(utility)
(let ((default-directory flycheck-test-source-directory))
(should (flycheck-same-files-p "flycheck.el" "flycheck.el"))))
(ert-deftest flycheck-same-files-p/different-files ()
:tags '(utility)
(let ((default-directory flycheck-test-source-directory))
(should-not (flycheck-same-files-p "flycheck.el" "Makefile"))))
(ert-deftest flycheck-same-files-p/file-in-non-existing-directory ()
:tags '(utility)
(let ((default-directory flycheck-test-source-directory))
(should-not (flycheck-same-files-p "flycheck.el" "foobar/flycheck.el"))))
(ert-deftest flycheck-same-files-p/non-existing-files ()
:tags '(utility)
(let ((default-directory flycheck-test-source-directory))
(should (flycheck-same-files-p "foobar/foobar" "foobar/foobar"))))
(ert-deftest flycheck-same-files-p/across-symlinks ()
:tags '(utility)
(skip-unless (fboundp #'make-symbolic-link))
(let ((directory (make-temp-file "flycheck-test-same-files-p-" 'directory)))
(unwind-protect
(let ((link (expand-file-name "foobar.el" directory))
(flycheck (expand-file-name "flycheck.el" flycheck-test-source-directory)))
(make-symbolic-link flycheck link)
(should (flycheck-same-files-p flycheck link)))
(delete-directory directory 'recursive))))
(ert-deftest flycheck-temp-dir-system ()
:tags '(utility)
(let ((dirname (flycheck-temp-dir-system)))
(unwind-protect
(should (file-directory-p dirname))
(flycheck-safe-delete-temporaries))
(should-not (file-exists-p dirname))
(should (string-prefix-p (file-name-as-directory
(file-truename temporary-file-directory))
(file-truename dirname)))
(should (string-prefix-p flycheck-temp-prefix
(file-name-nondirectory
(directory-file-name dirname))))))
(ert-deftest flycheck-temp-file-system/without-file-name ()
:tags '(utility)
(let ((filename (flycheck-temp-file-system nil)))
(unwind-protect
(should (file-exists-p filename))
(flycheck-safe-delete-temporaries))
(should-not (file-exists-p filename))
(should (string-prefix-p (file-name-as-directory
(file-truename temporary-file-directory))
(file-truename filename)))
(should (string-prefix-p flycheck-temp-prefix
(file-name-nondirectory filename)))))
(ert-deftest flycheck-temp-file-system/with-complete-path ()
:tags '(utility)
(let* ((filename (flycheck-temp-file-system "spam/with/eggs.el"))
(dirname (directory-file-name (file-name-directory filename))))
(unwind-protect
(progn
;; The file is not implicitly created, but the temporary directory is.
(should-not (file-exists-p filename))
(should (file-directory-p dirname)))
(flycheck-safe-delete-temporaries))
(should-not (file-exists-p filename))
(should-not (file-directory-p dirname))
;; The file name should be preserved. The temporary file should reside in a
;; subdirectory of the temporary directory
(should (string= "eggs.el" (file-name-nondirectory filename)))
(should (string-prefix-p flycheck-temp-prefix
(file-name-nondirectory
(directory-file-name dirname))))
(should (string-prefix-p flycheck-temp-prefix
(file-name-nondirectory
(directory-file-name dirname))))))
(ert-deftest flycheck-temp-file-inplace/with-just-basename ()
:tags '(utility)
(let* ((default-directory flycheck-test-directory)
(filename (flycheck-temp-file-inplace "eggs.el")))
(unwind-protect
;; In place files should not be created early
(should-not (file-exists-p filename))
(flycheck-safe-delete-temporaries))
(should (string= filename (expand-file-name
(concat flycheck-temp-prefix "_eggs.el"))))))
(ert-deftest flycheck-temp-file-inplace/with-complete-path ()
:tags '(utility)
(let* ((default-directory flycheck-test-directory)
(filename (flycheck-temp-file-inplace "spam/with/eggs.el")))
(unwind-protect
(should-not (file-exists-p filename))
(flycheck-safe-delete-temporaries))
(should (string= filename (expand-file-name (concat "spam/with/"
flycheck-temp-prefix
"_eggs.el"))))))
(ert-deftest flycheck-temp-file-inplace/without-file-name ()
:tags '(utility)
(let ((filename (flycheck-temp-file-inplace nil)))
(unwind-protect
(should (file-exists-p filename))
(flycheck-safe-delete-temporaries))
(should-not (file-name-extension filename))
(should (string-prefix-p flycheck-temp-prefix
(file-name-nondirectory filename)))))
(ert-deftest flycheck-save-buffer-to-file ()
:tags '(utility)
(let ((filename (expand-file-name "tests-temp")))
(unwind-protect
(progn
(flycheck-ert-with-temp-buffer
(should-not (file-exists-p filename))
(insert "Hello world")
(flycheck-save-buffer-to-file filename))
(should (file-exists-p filename))
(should (string= "Hello world" (with-temp-buffer
(insert-file-contents filename)
(buffer-string)))))
(ignore-errors (delete-file filename)))))
(ert-deftest flycheck-prepend-with-option/empty-list ()
:tags '(utility)
(should-not (flycheck-prepend-with-option "-f" nil)))
(ert-deftest flycheck-prepend-with-option/default-prepend-function ()
:tags '(utility)
(should (equal (flycheck-prepend-with-option "-L" '("foo" "bar"))
'("-L" "foo" "-L" "bar"))))
(ert-deftest flycheck-prepend-with-option/prepend-by-string-concatentation ()
:tags '(utility)
(should (equal (flycheck-prepend-with-option "-L" '("foo" "bar") #'concat)
'("-Lfoo" "-Lbar"))))
(ert-deftest flycheck-find-in-buffer/returns-first-match-on-success ()
:tags '(utility)
(with-temp-buffer
(insert "foo\nbar")
(should (string= "bar" (flycheck-find-in-buffer (rx (group "bar")))))))
(ert-deftest flycheck-find-in-buffer/returns-nil-on-failure ()
:tags '(utility)
(with-temp-buffer
(insert "spam\nwith eggs")
(should-not (flycheck-find-in-buffer (rx (group "bar"))))))
(ert-deftest flycheck-find-in-buffer/saves-excursion ()
:tags '(utility)
(with-temp-buffer
(insert "spam\nwith eggs")
(goto-char (point-min))
(forward-line)
(should (flycheck-find-in-buffer (rx (group "spam"))))
(should (= (point) 6))))
(ert-deftest flycheck-find-in-buffer/ ()
(with-temp-buffer
(insert "spam\nwith eggs")
(should-not (flycheck-find-in-buffer (rx (group "bar"))))))
(ert-deftest flycheck-ephemeral-buffer-p/temporary-buffer ()
:tags '(utility)
(flycheck-ert-with-temp-buffer
(should (flycheck-ephemeral-buffer-p))))
(ert-deftest flycheck-ephemeral-buffer-p/buffer-with-leading-whitespace ()
:tags '(utility)
(flycheck-ert-with-temp-buffer
(rename-buffer " foo")
(should (flycheck-ephemeral-buffer-p))))
(ert-deftest flycheck-ephemeral-buffer-p/buffer-without-leading-whitespace ()
:tags '(utility)
(flycheck-ert-with-temp-buffer
(rename-buffer "foo")
(should-not (flycheck-ephemeral-buffer-p))))
(ert-deftest flycheck-autoloads-file-p/ephemeral-buffer ()
:tags '(utility)
(flycheck-ert-with-temp-buffer
(should-not (flycheck-autoloads-file-p))))
(ert-deftest flycheck-autoloads-file-p/autoloads-without-backing-file ()
:tags '(utility)
(flycheck-ert-with-temp-buffer
(rename-buffer "foo-autoloads.el")
(should (flycheck-autoloads-file-p))))
(ert-deftest flycheck-autoloads-file-p/autoloads-with-backing-file ()
:tags '(utility)
(flycheck-ert-with-file-buffer (locate-library "shut-up-autoloads")
(should (flycheck-autoloads-file-p))))
(ert-deftest flycheck-autoloads-file-p/a-plain-file ()
:tags '(utility)
(flycheck-ert-with-file-buffer
(expand-file-name "Cask" flycheck-test-source-directory)
(should-not (flycheck-autoloads-file-p))))
(ert-deftest flycheck-in-user-emacs-directory-p/no-child-of-user-emacs-directory ()
:tags '(utility)
(should-not (flycheck-in-user-emacs-directory-p
(flycheck-ert-resource-filename
"language/emacs-lisp/warnings.el"))))
(ert-deftest flycheck-in-user-emacs-directory-p/direct-child-of-user-emacs-directory ()
:tags '(utility)
(let ((user-emacs-directory flycheck-test-directory))
(should (flycheck-in-user-emacs-directory-p
(expand-file-name "flycheck-test.el" flycheck-test-directory)))))
(ert-deftest flycheck-in-user-emacs-directory-p/indirect-child-of-user-emacs-directory ()
:tags '(utility)
(let ((user-emacs-directory flycheck-test-directory))
(should (flycheck-in-user-emacs-directory-p
(flycheck-ert-resource-filename
"language/emacs-lisp/warnings.el")))))
(ert-deftest flycheck-safe-delete/recursive-removal ()
:tags '(utility)
(let ((dirname (flycheck-temp-dir-system)))
(unwind-protect
(let ((filename (expand-file-name "foo" dirname)))
(process-lines "touch" filename)
(should (string-prefix-p dirname filename))
(should (file-exists-p filename))
(flycheck-safe-delete dirname)
(should-not (file-exists-p filename))
(should-not (file-directory-p dirname))
(should-not (file-exists-p dirname)))
(ignore-errors (delete-directory dirname 'recurse)))))
(ert-deftest flycheck-module-root-directory/no-module-name-and-no-file-name ()
:tags '(utility)
(let ((default-directory flycheck-test-resources-directory))
(should (string= flycheck-test-resources-directory
(flycheck-module-root-directory nil)))))
(ert-deftest flycheck-module-root-directory/no-module-name ()
:tags '(utility)
(let ((default-directory flycheck-test-resources-directory)
(file-name (flycheck-ert-resource-filename
"language/emacs-lisp/warnings.el")))
(should (string= (flycheck-ert-resource-filename "language/emacs-lisp/")
(flycheck-module-root-directory nil file-name)))))
(ert-deftest flycheck-module-root-directory/module-name-as-string ()
:tags '(utility)
(let ((default-directory flycheck-test-resources-directory)
(file-name (flycheck-ert-resource-filename "language/emacs-lisp/warnings.el")))
(should (string= flycheck-test-resources-directory
(flycheck-module-root-directory "language.emacs-lisp.warnings"
file-name)))))
(ert-deftest flycheck-module-root-directory/module-name-as-list ()
:tags '(utility)
(let ((default-directory flycheck-test-resources-directory)
(file-name (flycheck-ert-resource-filename "language/emacs-lisp/warnings.el")))
(should (string= flycheck-test-resources-directory
(flycheck-module-root-directory '("language" "emacs-lisp"
"warnings")
file-name)))))
(ert-deftest flycheck-module-root-directory/mismatching-module-name ()
:tags '(utility)
(let ((default-directory flycheck-test-resources-directory)
(file-name (flycheck-ert-resource-filename "language/emacs-lisp/warnings.el")))
(should (string= (flycheck-ert-resource-filename "language/emacs-lisp/")
(flycheck-module-root-directory '("foo" "warnings")
file-name)))))
;;; Checker API
(ert-deftest flycheck-valid-checker-p/not-a-symbol ()
:tags '(checker-api)
(should-not (flycheck-valid-checker-p "foo")))
(ert-deftest flycheck-valid-checker-p/no-checker-version ()
:tags '(checker-api)
(should-not (get 'foo 'flycheck-generic-checker-version))
(should-not (flycheck-valid-checker-p 'foo)))
(ert-deftest flycheck-valid-checker-p/checker-version-too-low ()
:tags '(checker-api)
(cl-letf* ((version (- flycheck-generic-checker-version 1))
((get 'foo 'flycheck-generic-checker-version) version))
(should (= (get 'foo 'flycheck-generic-checker-version) version))
(should-not (flycheck-valid-checker-p 'foo)))
(should-not (get 'foo 'flycheck-generic-checker-version)))
(ert-deftest flycheck-valid-checker-p/checker-version-too-high ()
:tags '(checker-api)
(cl-letf* ((version (+ flycheck-generic-checker-version 1))
((get 'foo 'flycheck-generic-checker-version) version))
(should (= (get 'foo 'flycheck-generic-checker-version) version))
(should-not (flycheck-valid-checker-p 'foo)))
(should-not (get 'foo 'flycheck-generic-checker-version)))
(ert-deftest flycheck-valid-checker-p/checker-version-ok ()
:tags '(checker-api)
(cl-letf* ((version flycheck-generic-checker-version)
((get 'foo 'flycheck-generic-checker-version) version))
(should (= (get 'foo 'flycheck-generic-checker-version) version))
(should (flycheck-valid-checker-p 'foo)))
(should-not (get 'foo 'flycheck-generic-checker-version)))
(ert-deftest flycheck-disabled-checker-p/enabled-checker ()
:tags '(checker-api)
(let ((flycheck-checkers '(emacs-lisp)))
(should-not (flycheck-disabled-checker-p 'emacs-lisp))))
(ert-deftest flycheck-disabled-checker-p/disabled-checker ()
:tags '(checker-api)
(let ((flycheck-disabled-checkers '(emacs-lisp)))
(should (flycheck-disabled-checker-p 'emacs-lisp))))
(defvar flycheck-test-config-var)
(defvar flycheck-test-option-var)
(ert-deftest flycheck-defined-checkers/are-valid ()
:tags '(checker-api)
(dolist (checker (flycheck-defined-checkers))
(should (flycheck-valid-checker-p checker))))
(ert-deftest flycheck-defined-checkers/are-registered ()
:tags '(checker-api)
(dolist (checker (flycheck-defined-checkers))
(should (flycheck-registered-checker-p checker))))
(ert-deftest flycheck-checker-executable/is-string ()
:tags '(checker-api)
(dolist (checker flycheck-checkers)
(should (stringp (flycheck-checker-executable checker)))))
(ert-deftest flycheck-checker-executable/override-the-executable ()
:tags '(checker-api)
(dolist (checker flycheck-checkers)
(let ((variable (flycheck-checker-executable-variable checker)))
(should (equal (eval `(let ((,variable "some-nice-executable"))
(flycheck-checker-executable ',checker)))
"some-nice-executable")))))
(ert-deftest flycheck-checker-get/modes ()
:tags '(checker-api)
(dolist (checker flycheck-checkers)
(should (listp (flycheck-checker-get checker 'modes)))
(should (-all? #'symbolp (flycheck-checker-get checker 'modes)))))
(ert-deftest flycheck-substitute-argument/source ()
:tags '(checker-api)
(flycheck-ert-with-resource-buffer "substitute-dummy"
(unwind-protect
(progn
(should (equal (flycheck-substitute-argument 'source-original 'emacs-lisp)
(list (buffer-file-name))))
(let ((filename (flycheck-substitute-argument 'source-inplace 'emacs-lisp)))
(should (equal filename (list (flycheck-ert-resource-filename
(concat flycheck-temp-prefix
"_substitute-dummy")))))
(should (file-exists-p (car filename))))
(let ((filename (flycheck-substitute-argument 'source 'emacs-lisp)))
(should (string-prefix-p temporary-file-directory (car filename)))
(should (file-exists-p (car filename))))))
(mapc #'flycheck-safe-delete flycheck-temporaries)))
(ert-deftest flycheck-substitute-argument/temporary-directory ()
:tags '(checker-api)
(unwind-protect
(let ((dirname (car (flycheck-substitute-argument 'temporary-directory
'emacs-lisp))))
(should (file-directory-p dirname))
(should (string-prefix-p temporary-file-directory dirname)))
(mapc #'flycheck-safe-delete flycheck-temporaries)))
(ert-deftest flycheck-substitute-argument/temporary-filename ()
:tags '(checker-api)
(unwind-protect
(let ((filename (car (flycheck-substitute-argument 'temporary-file-name
'emacs-lisp))))
;; The filename should not exist, but it's parent directory should
(should-not (file-exists-p filename))
(should (file-directory-p (file-name-directory filename)))
(should (string-prefix-p temporary-file-directory filename))
(should (member (directory-file-name (file-name-directory filename))
flycheck-temporaries)))
(mapc #'flycheck-safe-delete flycheck-temporaries)))
(ert-deftest flycheck-substitute-argument/null-device ()
:tags '(checker-api)
(should (equal (flycheck-substitute-argument 'null-device 'emacs-lisp)
(list null-device))))
(ert-deftest flycheck-substitute-argument/config-file ()
:tags '(checker-api)
(let* ((flycheck-test-config-var "substitute-dummy")
(config-file (flycheck-ert-resource-filename "substitute-dummy"))
first-args second-args
(locate-nil (lambda (&rest args) (setq first-args args) nil))
(locate-real (lambda (&rest args) (setq second-args args)
config-file))
(flycheck-locate-config-file-functions (list locate-nil locate-real)))
(should (equal (flycheck-substitute-argument
'(config-file "--foo" flycheck-test-config-var)
'emacs-lisp)
(list "--foo" config-file)))
(should (equal first-args (list "substitute-dummy" 'emacs-lisp)))
(should (equal second-args (list "substitute-dummy" 'emacs-lisp)))
(setq first-args nil
second-args nil)
(should (equal (flycheck-substitute-argument
'(config-file "--foo=" flycheck-test-config-var concat)
'emacs-lisp)
(list (concat "--foo=" config-file))))))
(ert-deftest flycheck-substitute-argument/option ()
:tags '(checker-api)
(let ((flycheck-test-option-var "bar"))
(should (equal (flycheck-substitute-argument
'(option "--foo" flycheck-test-option-var) 'emacs-lisp)
'("--foo" "bar")))
(should (equal (flycheck-substitute-argument
'(option "--foo=" flycheck-test-option-var concat)
'emacs-lisp)
'("--foo=bar"))))
(let ((flycheck-test-option-var 200))
(should-error (flycheck-substitute-argument
'(option "--foo" flycheck-test-option-var) 'emacs-lisp))
(should (equal (flycheck-substitute-argument
'(option "--foo" flycheck-test-option-var nil number-to-string)
'emacs-lisp)
'("--foo" "200")))
(should (equal (flycheck-substitute-argument
'(option "--foo=" flycheck-test-option-var concat number-to-string) 'emacs-lisp)
'("--foo=200"))))
(let (flycheck-test-option-var)
(should-not (flycheck-substitute-argument
'(option "--foo" flycheck-test-option-var) 'emacs-lisp))
;; Catch an error, because `number-to-string' is called with nil
(should-error (flycheck-substitute-argument
'(option "--foo" flycheck-test-option-var nil number-to-string)
'emacs-lisp)
:type 'wrong-type-argument)
(should-error (flycheck-substitute-argument
'(option "--foo=" flycheck-test-option-var concat number-to-string)
'emacs-lisp)
:type 'wrong-type-argument)))
(ert-deftest flycheck-substitute-argument/option-list ()
:tags '(checker-api)
(let ((flycheck-test-option-var "spam"))
(should-error (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var) 'emacs-lisp)))
(let ((flycheck-test-option-var '("spam" "eggs")))
(should (equal (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var) 'emacs-lisp)
'("-I" "spam" "-I" "eggs")))
(should (equal (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var concat) 'emacs-lisp)
'("-Ispam" "-Ieggs"))))
(let ((flycheck-test-option-var '(10 20)))
(should-error (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var) 'emacs-lisp))
(should (equal (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var nil number-to-string) 'emacs-lisp)
'("-I" "10" "-I" "20")))
(should (equal (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var
concat number-to-string) 'emacs-lisp)
'("-I10" "-I20"))))
(let (flycheck-test-option-var)
(should-not (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var) 'emacs-lisp)))
(let ((flycheck-test-option-var '(nil)))
;; Catch an error, because `number-to-string' is called with nil
(should-error (flycheck-substitute-argument
'(option-list "-I" flycheck-test-option-var nil number-to-string) 'emacs-lisp)
:type 'wrong-type-argument)))
(ert-deftest flycheck-substitute-argument/option-flag ()
:tags '(checker-api)
(let ((flycheck-test-option-var nil))
(should-not (flycheck-substitute-argument
'(option-flag "--foo" flycheck-test-option-var) 'emacs-lisp)))
(let ((flycheck-test-option-var t))
(should (equal (flycheck-substitute-argument
'(option-flag "--foo" flycheck-test-option-var) 'emacs-lisp)
(list "--foo"))))
(let ((flycheck-test-option-var (list "bar")))
(should (equal (flycheck-substitute-argument
'(option-flag "--foo" flycheck-test-option-var) 'emacs-lisp)
(list "--foo")))))
(ert-deftest flycheck-substitute-argument/eval ()
:tags '(checker-api)
(let ((flycheck-test-option-var '("Hello " "World")))
(should (equal (flycheck-substitute-argument '(eval flycheck-test-option-var) 'emacs-lisp)
'("Hello " "World"))))
(should (equal (flycheck-substitute-argument '(eval (concat "Hello" "World")) 'emacs-lisp)
'("HelloWorld")))
(should-not (flycheck-substitute-argument
'(eval (when (string= "foo" "bar") "yes")) 'emacs-lisp))
(should-error (flycheck-substitute-argument '(eval 200) 'emacs-lisp))
(should-error (flycheck-substitute-argument '(eval '("foo" 200)) 'emacs-lisp)))
(ert-deftest flycheck-substitute-argument/unknown ()
:tags '(checker-api)
(should-error (flycheck-substitute-argument '(foo "bar") 'emacs-lisp))
(should-error (flycheck-substitute-argument 200 'emacs-lisp)))
(ert-deftest flycheck-may-use-checker/invalid-checker ()
:tags '(checker-api)
(should-not (flycheck-valid-checker-p 'foo))
(should-not (flycheck-may-use-checker 'foo)))
(ert-deftest flycheck-may-use-checker/disabled-checker ()
:tags '(checker-api)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-may-use-checker 'emacs-lisp)
(let ((flycheck-disabled-checkers '(emacs-lisp)))
(should-not (flycheck-may-use-checker 'emacs-lisp)))))
(ert-deftest flycheck-may-use-checker/checks-executable ()
:tags '(checker-api)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(let* ((was-called nil)
(flycheck-executable-find (lambda (_) (setq was-called t))))
(should (flycheck-may-use-checker 'emacs-lisp))
(should was-called))))
(ert-deftest flycheck-may-enable-checker/emacs-lisp ()
:tags '(checker-api)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(should (flycheck-may-enable-checker 'emacs-lisp))
(should (equal '(emacs-lisp) flycheck-enabled-checkers))))
;;; Generic syntax checkers
(ert-deftest flycheck-checker-get/gets-a-property ()
:tags '(generic-checkers)
(should (equal (flycheck-checker-get 'emacs-lisp 'modes)
'(emacs-lisp-mode lisp-interaction-mode))))
(ert-deftest flycheck-checker-get/setf ()
:tags '(generic-checkers)
(let ((checker 'bar)
(property 'foo))
(should-not (flycheck-checker-get checker property))
(setf (flycheck-checker-get checker property) "Hello world")
(unwind-protect
(should (equal (flycheck-checker-get checker property)
"Hello world"))
(put checker 'flycheck-foo nil))))
(ert-deftest flycheck-validate-next-checker/any-symbol ()
:tags '(definition)
(should (flycheck-validate-next-checker 'foo))
(should-error (flycheck-validate-next-checker 'foo t)))
(ert-deftest flycheck-validate-next-checker/syntax-checker-symbol ()
:tags '(definition)
(should (flycheck-validate-next-checker 'emacs-lisp t)))
(ert-deftest flycheck-validate-next-checker/string ()
:tags '(definition)
(should-error (flycheck-validate-next-checker "foo")))
(ert-deftest flycheck-validate-next-checker/invalid-form ()
:tags '(definition)
(should-error (flycheck-validate-next-checker '(warnings-only emacs-lisp))))
(ert-deftest flycheck-validate-next-checker/invalid-level ()
:tags '(definition)
(should-error (flycheck-validate-next-checker '("foo" . emacs-lisp)))
(should-error (flycheck-validate-next-checker '(foo . emacs-lisp) 'strict)))
(ert-deftest flycheck-validate-next-checker/valid-predicate-with-any-symbol ()
:tags '(definition)
(should (flycheck-validate-next-checker '(warning . bar)))
(should-error (flycheck-validate-next-checker '(warning . bar) 'strict)))
(ert-deftest flycheck-validate-next-checker/valid-predicate-with-syntax-checker-symbol ()
:tags '(definition)
(should (flycheck-validate-next-checker '(warning . emacs-lisp) 'strict)))
;;; Checker extensions
(ert-deftest flycheck-add-next-checker/no-valid-checker ()
:tags '(extending)
(let ((err-data (should-error (flycheck-add-next-checker 'foo 'emacs-lisp))))
(should (string= (cadr err-data) "foo is not a valid syntax checker"))))
(ert-deftest flycheck-add-next-checker/no-valid-next-checker ()
:tags '(extending)
(should-error (flycheck-add-next-checker 'emacs-lisp '(warnings-only bar)))
(should-error (flycheck-add-next-checker 'emacs-lisp "foo"))
(should-error (flycheck-add-next-checker 'emacs-lisp 'bar))
(should-error (flycheck-add-next-checker 'emacs-lisp '(warnings-only . bar)))
(should-error (flycheck-add-next-checker 'emacs-lisp '(foo . emacs-lisp))))
(ert-deftest flycheck-add-next-checker/prepend ()
:tags '(extending)
(let ((next-checkers (flycheck-checker-get 'emacs-lisp 'next-checkers)))
(flycheck-add-next-checker 'emacs-lisp 'texinfo)
(unwind-protect
(should (equal (flycheck-checker-get 'emacs-lisp 'next-checkers)
(cons 'texinfo next-checkers)))
(put 'emacs-lisp 'flycheck-next-checkers next-checkers)
(should (equal (flycheck-checker-get 'emacs-lisp 'next-checkers)
next-checkers)))))
(ert-deftest flycheck-add-next-checker/append ()
:tags '(extending)
(let ((next-checkers (flycheck-checker-get 'emacs-lisp 'next-checkers)))
(flycheck-add-next-checker 'emacs-lisp 'texinfo 'append)
(unwind-protect
(should (equal (flycheck-checker-get 'emacs-lisp 'next-checkers)
(append next-checkers '(texinfo))))
(put 'emacs-lisp 'flycheck-next-checkers next-checkers)
(should (equal (flycheck-checker-get 'emacs-lisp 'next-checkers)
next-checkers)))))
(ert-deftest flycheck-add-mode/no-valid-checker ()
:tags '(extending)
(let ((err-data (should-error (flycheck-add-mode 'foo 'emacs-lisp-mode))))
(should (string= (cadr err-data) "foo is not a valid syntax checker"))))
(ert-deftest flycheck-add-mode/no-valid-mode ()
:tags '(extending)
(let ((err-data (should-error (flycheck-add-mode 'python-pylint "foo"))))
(should (string= (cadr err-data) "foo is not a symbol"))))
(ert-deftest flycheck-add-mode ()
:tags '(extending)
(let ((modes (flycheck-checker-get 'python-pylint 'modes)))
(flycheck-add-mode 'python-pylint 'emacs-lisp-mode)
(unwind-protect
(progn
(should (equal (flycheck-checker-get 'python-pylint 'modes)
(cons 'emacs-lisp-mode modes))))
(put 'python-pylint 'flycheck-modes modes)
(should (equal (flycheck-checker-get 'python-pylint 'modes) modes)))))
;;; Syntax checking mode
(ert-deftest flycheck-mode/enables-standard-error-navigation ()
:tags '(minor-mode)
(flycheck-ert-with-temp-buffer
(setq next-error-function :old)
(flycheck-mode 1)
(should flycheck-mode)
(should (eq next-error-function 'flycheck-next-error-function))
(flycheck-mode -1)
(should-not flycheck-mode)
(should (eq next-error-function :old))))
(ert-deftest flycheck-mode/does-not-enable-standard-error-navigation ()
:tags '(minor-mode)
(flycheck-ert-with-temp-buffer
(let ((flycheck-standard-error-navigation nil))
(setq next-error-function :old)
(flycheck-mode +1)
(should flycheck-mode)
(should (eq next-error-function :old))
(should (eq flycheck-old-next-error-function :unset))
(setq next-error-function :new)
(flycheck-mode -1)
(should-not flycheck-mode)
;; Disabling the mode should not affect `next-error-function' now
(should (eq next-error-function :new)))))
(ert-deftest flycheck-mode/clears-errors-after-revert ()
:tags '(minor-mode language-emacs-lisp)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(goto-char (point-min))
(insert "foo-bar")
(flycheck-mode)
(flycheck-ert-buffer-sync)
(should flycheck-current-errors)
(let ((hack-local-variables-hook))
(revert-buffer 'ignore-auto 'no-confirm))
(should-not flycheck-current-errors)
(should-not (flycheck-deferred-check-p))))
;;; Syntax checker selection for the current buffer
(ert-deftest flycheck-checker/unusable-checker-causes-an-error ()
:tags '(selection)
(flycheck-ert-with-temp-buffer
(emacs-lisp-mode)
(flycheck-mode)
(let* ((flycheck-checker 'sh-bash))
(should-error (flycheck-buffer))
(should (eq flycheck-checker 'sh-bash))
(should (string= flycheck-last-status-change 'errored)))))
(ert-deftest flycheck-checker/usable-checker-is-used ()
:tags '(selection language-emacs-lisp checker-emacs-lisp-checkdoc)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
(should (eq (flycheck-get-checker-for-buffer) 'emacs-lisp))
(let ((flycheck-checker 'emacs-lisp-checkdoc))
(should (eq (flycheck-get-checker-for-buffer) 'emacs-lisp-checkdoc))
(flycheck-ert-buffer-sync)
(flycheck-ert-should-errors
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc)))))
(ert-deftest flycheck-checker/disabled-checker-is-not-used ()
:tags '(selection language-emacs-lisp)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
(let ((flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc)))
(should-not (flycheck-get-checker-for-buffer))
(let* ((flycheck-checker 'emacs-lisp))
(should-error (flycheck-buffer))
(should (eq flycheck-checker 'emacs-lisp))
(should (string= flycheck-last-status-change 'errored))))))
(ert-deftest flycheck-checker/unregistered-checker-is-used ()
:tags '(selection language-emacs-lisp checker-emacs-lisp-checkdoc)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
(should (eq (flycheck-get-checker-for-buffer) 'emacs-lisp))
(let ((flycheck-checkers (remq 'emacs-lisp-checkdoc flycheck-checkers)))
(should-not (flycheck-registered-checker-p 'emacs-lisp-checkdoc))
(let ((flycheck-checker 'emacs-lisp-checkdoc))
(should (eq (flycheck-get-checker-for-buffer) 'emacs-lisp-checkdoc))
(flycheck-ert-buffer-sync)
(flycheck-ert-should-errors
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc))))))
(ert-deftest flycheck-select-checker/selecting-sets-the-syntax-checker ()
:tags '(selection checker-emacs-lisp-checkdoc)
(flycheck-ert-with-temp-buffer
(emacs-lisp-mode)
(flycheck-select-checker 'emacs-lisp-checkdoc)
(should (eq flycheck-checker 'emacs-lisp-checkdoc))))
(ert-deftest flycheck-select-checker/unselecting-unsets-the-syntax-checker ()
:tags '(selection checker-emacs-lisp-checkdoc)
(flycheck-ert-with-temp-buffer
(emacs-lisp-mode)
(flycheck-select-checker 'emacs-lisp-checkdoc)
(flycheck-select-checker nil)
(should-not flycheck-checker)))
(ert-deftest flycheck-select-checker/selecting-runs-a-syntax-check ()
:tags '(selection language-emacs-lisp
checker-emacs-lisp checker-emacs-lisp-checkdoc)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
;; By default we should get both, because emacs-lisp chains to checkdoc
(flycheck-ert-buffer-sync)
(dolist (err flycheck-current-errors)
(should (memq (flycheck-error-checker err)
'(emacs-lisp emacs-lisp-checkdoc))))
;; We select checkdoc, and should now only have checkdoc errors
(flycheck-select-checker 'emacs-lisp-checkdoc)
(flycheck-ert-wait-for-syntax-checker)
(dolist (err flycheck-current-errors)
(should (eq (flycheck-error-checker err) 'emacs-lisp-checkdoc)))))
(ert-deftest flycheck-select-checker/unselecting-a-checker-goes-back-to-automatic-selection ()
:tags '(selection language-emacs-lisp
checker-emacs-lisp checker-emacs-lisp-checkdoc)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
(flycheck-select-checker 'emacs-lisp-checkdoc)
(should (eq flycheck-checker 'emacs-lisp-checkdoc))
(flycheck-ert-wait-for-syntax-checker)
(dolist (err flycheck-current-errors)
(should (eq (flycheck-error-checker err) 'emacs-lisp-checkdoc)))
(flycheck-select-checker nil)
(should-not flycheck-checker)
(flycheck-ert-wait-for-syntax-checker)
(dolist (err flycheck-current-errors)
(should (memq (flycheck-error-checker err)
'(emacs-lisp emacs-lisp-checkdoc))))))
(ert-deftest flycheck/selects-checker-automatically/no-disabled-checker ()
:tags '(selection language-emacs-lisp checker-emacs-lisp-checkdoc)
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(let ((flycheck-disabled-checkers '(emacs-lisp)))
(flycheck-ert-buffer-sync)
(should-not flycheck-checker)
(flycheck-ert-should-errors
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc)))))
(ert-deftest flycheck-disable-checker/disables-checker ()
:tags '(selection)
(flycheck-ert-with-temp-buffer
(flycheck-mode)
(with-no-warnings
(flycheck-disable-checker 'emacs-lisp))
(should (equal '(emacs-lisp) flycheck-disabled-checkers))
(should-not (default-value 'flycheck-disabled-checkers))
;; Disabling a disabled checker should be a no-op
(with-no-warnings
(flycheck-disable-checker 'emacs-lisp))
(should (equal '(emacs-lisp) flycheck-disabled-checkers))))
(ert-deftest flycheck-disable-checker/enables-checker ()
:tags '(selection)
(flycheck-ert-with-temp-buffer
(flycheck-mode)
(setq flycheck-disabled-checkers '(emacs-lisp python-pylint))
(with-no-warnings
(flycheck-disable-checker 'emacs-lisp 'enable))
(should (equal '(python-pylint) flycheck-disabled-checkers))))
;;; Automatic syntax checking in a buffer
(ert-deftest flycheck-may-check-automatically/not-in-ephemeral-buffers ()
:tags '(automatic)
(flycheck-ert-with-temp-buffer
(should-not (-any? #'flycheck-may-check-automatically
'(save idle-change new-line mode-enabled)))
(should-not (flycheck-may-check-automatically))))
(ert-deftest flycheck-may-check-automatically/in-normal-buffers ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(should (-all? #'flycheck-may-check-automatically
'(save idle-change new-line mode-enabled)))
(should (flycheck-may-check-automatically))))
(ert-deftest flycheck-may-check-automatically/automatic-checking-disabled ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(let ((flycheck-check-syntax-automatically nil))
(should-not (-any? #'flycheck-may-check-automatically
'(save idle-change new-line mode-enabled)))
(should (flycheck-may-check-automatically)))))
(ert-deftest flycheck-may-check-automatically/specific-event-disabled ()
:tags '(automatic)
(dolist (event '(save idle-change new-line mode-enabled))
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
;; Disable just a specific event
(let ((flycheck-check-syntax-automatically
(remq event flycheck-check-syntax-automatically)))
(should flycheck-check-syntax-automatically)
(should-not (flycheck-may-check-automatically event))
(should (-all? #'flycheck-may-check-automatically
flycheck-check-syntax-automatically))
(should (flycheck-may-check-automatically))))))
(ert-deftest flycheck-check-syntax-automatically/mode-enabled-is-disabled ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(emacs-lisp-mode)
(should-not (flycheck-deferred-check-p))
(let ((flycheck-check-syntax-automatically
(remq 'mode-enabled flycheck-check-syntax-automatically)))
(flycheck-mode)
(should-not (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/mode-enabled-checks-syntax-after-flycheck-mode ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(emacs-lisp-mode)
(should-not (flycheck-deferred-check-p))
(let ((flycheck-check-syntax-automatically '(mode-enabled)))
(flycheck-mode)
(should (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/idle-change-is-disabled ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(emacs-lisp-mode)
(let ((flycheck-check-syntax-automatically nil))
(flycheck-mode))
(let ((flycheck-check-syntax-automatically
(remq 'idle-change flycheck-check-syntax-automatically)))
(insert "Hello world")
(sleep-for 0.55)
(should-not (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/idle-change-checks-syntax-after-change ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(emacs-lisp-mode)
(let ((flycheck-check-syntax-automatically '(idle-change)))
(flycheck-mode)
(insert "Hello world")
(should-not (flycheck-deferred-check-p))
(sleep-for 0.55)
(should (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/idle-change-does-not-check-before-delay ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(emacs-lisp-mode)
(let ((flycheck-check-syntax-automatically '(idle-change))
(flycheck-idle-change-delay 1.5))
(flycheck-mode)
(insert "Hello world")
(sleep-for 0.55)
(should-not (flycheck-deferred-check-p))
(sleep-for 1.1)
(should (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/new-line-is-disabled ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(let ((flycheck-check-syntax-automatically nil))
(flycheck-mode))
(let ((flycheck-check-syntax-automatically
(remq 'new-line flycheck-check-syntax-automatically)))
(insert "\n")
(should-not (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/new-line-checks-syntax-after-new-line ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(let ((flycheck-check-syntax-automatically '(new-line)))
(flycheck-mode)
(insert "\n")
(should (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/save-disabled ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(let ((flycheck-check-syntax-automatically nil))
(flycheck-mode))
(set-buffer-modified-p t)
(let ((flycheck-check-syntax-automatically
(remq 'save flycheck-check-syntax-automatically)))
(save-buffer 0)
(should-not (flycheck-deferred-check-p)))))
(ert-deftest flycheck-check-syntax-automatically/save-checks-syntax-after-save ()
:tags '(automatic)
(flycheck-ert-with-resource-buffer "automatic-check-dummy.el"
(let ((flycheck-check-syntax-automatically '(save)))
(flycheck-mode)
(set-buffer-modified-p t)
(save-buffer 0)
(should (flycheck-deferred-check-p)))))
(ert-deftest flycheck-buffer-automatically/does-not-check-with-disabled-mode ()
:tags '(automatic)
(flycheck-ert-with-temp-buffer
(rename-buffer "foo")
(should-not flycheck-mode)
(should-not (flycheck-deferred-check-p))
(flycheck-buffer-automatically)
(should-not (flycheck-deferred-check-p))))
(ert-deftest flycheck-buffer-automatically/defers-the-test ()
:tags '(automatic)
(flycheck-ert-with-temp-buffer
(flycheck-mode)
;; Flycheck won't check ephemeral buffers
(rename-buffer "foo")
(should-not (flycheck-deferred-check-p))
(flycheck-buffer-automatically)
(should (flycheck-deferred-check-p))))
;;; Deferred syntax checking
(ert-deftest flycheck-deferred-check-p/nil ()
:tags '(deferred)
(let ((flycheck-deferred-syntax-check nil))
(should-not (flycheck-deferred-check-p))))
(ert-deftest flycheck-deferred-check-p/truthy ()
:tags '(deferred)
(let ((flycheck-deferred-syntax-check t))
(should (flycheck-deferred-check-p))))
(ert-deftest flycheck-buffer-deferred/schedules-a-deferred-syntax-check ()
:tags '(deferred)
(flycheck-ert-with-temp-buffer
(should-not (flycheck-deferred-check-p))
(flycheck-buffer-deferred)
(should (flycheck-deferred-check-p))))
(ert-deftest flycheck-clean-deferred-check/removes-a-deferred-syntax-check ()
:tags '(deferred)
(flycheck-ert-with-temp-buffer
(flycheck-buffer-deferred)
(flycheck-clean-deferred-check)
(should-not (flycheck-deferred-check-p))))
;;; Errors from syntax checks
(ert-deftest flycheck-error-line-region ()
:tags '(error-api)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World\n")
(should (equal (flycheck-error-line-region (flycheck-error-new-at 1 1))
'(1 . 6)))
(should (equal (flycheck-error-line-region (flycheck-error-new-at 2 4))
'(11 . 16)))
;; An error column beyond the end of the line is simply ignored just like
;; all other error columns
(should (equal (flycheck-error-line-region (flycheck-error-new-at 2 10))
'(11 . 16)))
;; An error line beyond the end of file should highlight the last line
(should (equal (flycheck-error-line-region (flycheck-error-new-at 4 3))
'(16 . 17)))))
(ert-deftest flycheck-error-column-region ()
:tags '(error-api)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World\n")
(should-not (flycheck-error-column-region (flycheck-error-new-at 1 nil)))
(should (equal (flycheck-error-column-region (flycheck-error-new-at 1 4))
'(4 . 5)))
(should (equal (flycheck-error-column-region (flycheck-error-new-at 2 6))
'(12 . 13)))
;; A column beyond the end of a line
(should (equal (flycheck-error-column-region (flycheck-error-new-at 1 7))
'(6 . 7)))
;; A column right at the end of the last empty line of a file (an important
;; special case, because the Emacs Lisp checker reports undefined functions
;; at this place!)
(should (equal (flycheck-error-column-region (flycheck-error-new-at 3 1))
'(16 . 17)))
;; A column beyond the end of file
(should (equal (flycheck-error-column-region (flycheck-error-new-at 4 2))
'(16 . 17)))))
(ert-deftest flycheck-error-thing-region ()
:tags '(error-api)
(flycheck-ert-with-temp-buffer
(insert " (message)\n (message")
(emacs-lisp-mode)
(should-not (flycheck-error-thing-region 'sexp (flycheck-error-new-at 1 2)))
(should (equal (flycheck-error-thing-region 'sexp (flycheck-error-new-at 1 5))
'(5 . 14)))
(should-not (flycheck-error-thing-region 'symbol (flycheck-error-new-at 1 5)))
(should (equal (flycheck-error-thing-region 'sexp (flycheck-error-new-at 1 8))
'(6 . 13)))
(should (equal (flycheck-error-thing-region 'symbol (flycheck-error-new-at 1 8))
'(6 . 13)))
;; An incomplete expression
(should-not (flycheck-error-thing-region 'sexp (flycheck-error-new-at 2 5)))))
(ert-deftest flycheck-error-region-for-mode ()
:tags '(error-api)
(flycheck-ert-with-temp-buffer
(insert " (message) ;; Hello world\n (message")
(emacs-lisp-mode)
;; Test an expression at the error column for all modes
(let ((err (flycheck-error-new-at 1 7)))
(should (equal (flycheck-error-region-for-mode err 'lines) '(5 . 29)))
(should (equal (flycheck-error-region-for-mode err 'columns) '(7 . 8)))
(should (equal (flycheck-error-region-for-mode err 'symbols) '(6 . 13)))
(should (equal (flycheck-error-region-for-mode err 'sexps) '(6 . 13))))
;; Test an error column which does not point to an expression
(let ((err (flycheck-error-new-at 2 5)))
(should (equal (flycheck-error-region-for-mode err 'lines) '(34 . 42)))
(dolist (mode '(columns symbols sexps))
(should (equal (flycheck-error-region-for-mode err mode) '(34 . 35)))))
;; Test an error without column for all modes
(let ((err (flycheck-error-new-at 1 nil)))
(dolist (mode '(lines columns symbols sexps))
(should (equal (flycheck-error-region-for-mode err mode) '(5 . 29)))))))
(ert-deftest flycheck-error-pos ()
:tags '(error-api)
(flycheck-ert-with-temp-buffer
(insert " Hello\n World\n")
(should (= (flycheck-error-pos (flycheck-error-new-at 1 1)) 1))
(should (= (flycheck-error-pos (flycheck-error-new-at 1 4)) 4))
(should (= (flycheck-error-pos (flycheck-error-new-at 1 nil)) 5))
(should (= (flycheck-error-pos (flycheck-error-new-at 2 nil)) 14))
(should (= (flycheck-error-pos (flycheck-error-new-at 3 1)) 19))
(should (= (flycheck-error-pos (flycheck-error-new-at 4 1)) 19))
(should (= (flycheck-error-pos (flycheck-error-new-at 4 nil)) 19))))
(ert-deftest flycheck-error-format-message-and-id/no-id ()
:tags '(error-api)
(should (string= (flycheck-error-format-message-and-id
(flycheck-error-new-at 3 5 'warning "Hello world"))
"Hello world")))
(ert-deftest flycheck-error-format-message-and-id/with-id ()
:tags '(error-api)
(should (string= (flycheck-error-format-message-and-id
(flycheck-error-new-at 3 5 'warning "Hello world"
:id "Foo"))
"Hello world [Foo]")))
(ert-deftest flycheck-error-format/level-warning ()
:tags '(error-api)
(should (string= (flycheck-error-format
(flycheck-error-new-at 3 5 'warning "Hello world"
:checker 'emacs-lisp))
"3:5:warning: Hello world (emacs-lisp)")))
(ert-deftest flycheck-error-format/level-error ()
:tags '(error-api)
(should (string= (flycheck-error-format
(flycheck-error-new-at 20 7 'error "Spam with eggs"
:checker 'ruby))
"20:7:error: Spam with eggs (ruby)")))
(ert-deftest flycheck-error-format/no-column ()
:tags '(error-api)
(should (string= (flycheck-error-format
(flycheck-error-new-at 14 nil 'warning "Oh no"
:checker 'python-flake8))
"14:warning: Oh no (python-flake8)")))
(ert-deftest flycheck-error-format/handles-line-breaks ()
:tags '(error-api)
;; Specific test for https://github.com/magnars/s.el/issues/34
(should (string= (flycheck-error-format
(flycheck-error-new-at 14 15 'error "dash\\nbroken"
:checker 'foo))
"14:15:error: dash\\nbroken (foo)")))
(ert-deftest flycheck-error-format/with-id ()
:tags '(error-api)
(should (string= (flycheck-error-format
(flycheck-error-new-at 14 15 'error "A message"
:id "E001" :checker 'foo))
"14:15:error: A message [E001] (foo)")))
(ert-deftest flycheck-error-</no-column ()
:tags '(error-api)
(should (flycheck-error-< (flycheck-error-new-at 10 nil)
(flycheck-error-new-at 11 nil)))
(should-not (flycheck-error-< (flycheck-error-new-at 10 nil)
(flycheck-error-new-at 10 nil)))
(should-not (flycheck-error-< (flycheck-error-new-at 10 nil)
(flycheck-error-new-at 9 nil))))
(ert-deftest flycheck-error-</by-line-with-column ()
:tags '(error-api)
(should (flycheck-error-< (flycheck-error-new-at 10 2)
(flycheck-error-new-at 11 1)))
(should-not (flycheck-error-< (flycheck-error-new-at 10 1)
(flycheck-error-new-at 9 2))))
(ert-deftest flycheck-error-</by-column ()
:tags '(error-api)
(should (flycheck-error-< (flycheck-error-new-at 10 10)
(flycheck-error-new-at 10 11)))
(should-not (flycheck-error-< (flycheck-error-new-at 10 10)
(flycheck-error-new-at 10 10)))
(should-not (flycheck-error-< (flycheck-error-new-at 10 11)
(flycheck-error-new-at 10 10))))
(ert-deftest flycheck-error-level-</by-level-severity ()
:tags '(error-api)
(should (flycheck-error-level-< (flycheck-error-new-at 10 nil 'info)
(flycheck-error-new-at 8 nil 'warning)))
(should-not (flycheck-error-level-< (flycheck-error-new-at 8 nil 'warning)
(flycheck-error-new-at 8 nil 'warning)))
(should-not (flycheck-error-level-< (flycheck-error-new-at 7 nil 'error)
(flycheck-error-new-at 8 nil 'warning))))
(ert-deftest flycheck-error-level-</by-level-name ()
:tags '(error-api)
(should (flycheck-error-level-< (flycheck-error-new-at 10 nil 'a)
(flycheck-error-new-at 8 nil 'b)))
(should-not (flycheck-error-level-< (flycheck-error-new-at 7 nil 'c)
(flycheck-error-new-at 8 nil 'b))))
(ert-deftest flycheck-error-level-</by-location ()
:tags '(error-api)
(should (flycheck-error-level-< (flycheck-error-new-at 8 nil 'info)
(flycheck-error-new-at 10 nil 'info)))
(should-not (flycheck-error-level-< (flycheck-error-new-at 8 nil 'info)
(flycheck-error-new-at 8 nil 'info)))
(should-not (flycheck-error-level-< (flycheck-error-new-at 8 nil 'info)
(flycheck-error-new-at 7 nil 'info))))
(ert-deftest flycheck-assert-error-list-p/all-flycheck-errors ()
:tags '(error-api)
(let ((errors (list (flycheck-error-new-at 8 10 nil 'info)
(flycheck-error-new-at 9 11 nil 'info))))
(should (eq (flycheck-assert-error-list-p errors) errors))))
(ert-deftest flycheck-assert-error-list-p/no-list ()
:tags '(error-api)
(let ((data (should-error (flycheck-assert-error-list-p 'foo)
:type 'wrong-type-argument)))
(should (equal (error-message-string data)
"Wrong type argument: listp, foo"))))
(ert-deftest flycheck-assert-error-list-p/nil-in-list ()
:tags '(error-api)
(let* ((errors (list (flycheck-error-new-at 8 10 nil 'info)
nil))
(data (should-error (flycheck-assert-error-list-p errors)
:type 'wrong-type-argument)))
(should (equal (error-message-string data)
"Wrong type argument: flycheck-error-p, nil"))))
(ert-deftest flycheck-assert-error-list-p/wrong-type-in-list ()
:tags '(error-api)
(let* ((errors (list (flycheck-error-new-at 8 10 nil 'info)
"foo"))
(data (should-error (flycheck-assert-error-list-p errors)
:type 'wrong-type-argument)))
(should (equal (error-message-string data)
"Wrong type argument: flycheck-error-p, \"foo\""))))
;;; Errors in the current buffer
(ert-deftest flycheck-fill-and-expand-error-file-names ()
:tags '(errors)
(flycheck-ert-with-resource-buffer "global-mode-dummy.el"
(let* ((absolute-fn (flycheck-ert-resource-filename "substitute-dummy"))
(cwd (file-name-directory absolute-fn))
(relative-fn (file-name-nondirectory absolute-fn))
(errors (list (flycheck-error-new :filename "foo")
(flycheck-error-new :filename absolute-fn)
(flycheck-error-new :filename relative-fn)
(flycheck-error-new :filename nil))))
(should (equal (mapcar #'flycheck-error-filename
(flycheck-fill-and-expand-error-file-names errors
cwd))
(list (flycheck-ert-resource-filename "foo")
absolute-fn
absolute-fn
(flycheck-ert-resource-filename
"global-mode-dummy.el")))))))
;;; Status reporting for the current buffer
(ert-deftest flycheck-report-status/runs-functions ()
:tags '(status-reporting)
(flycheck-ert-with-temp-buffer
(let* ((was-called nil)
(flycheck-status-changed-functions
(list (lambda (status) (setq was-called status)))))
(flycheck-report-status 'running)
(should (eq was-called 'running)))))
(ert-deftest flycheck-report-failed-syntax-check/runs-hook ()
:tags '(status-reporting)
(flycheck-ert-with-temp-buffer
(let* ((was-called nil)
(flycheck-syntax-check-failed-hook
(list (lambda () (setq was-called t)))))
(flycheck-report-failed-syntax-check)
(should was-called))))
(ert-deftest flycheck-report-failed-syntax-check/clears-errors ()
:tags '(status-reporting)
(flycheck-ert-with-temp-buffer
(let ((flycheck-current-errors (list 'foo)))
(flycheck-report-failed-syntax-check)
(should-not flycheck-current-errors))))
;;; Error levels
;; A level for the following unit tests
(flycheck-define-error-level 'test-level
:severity 1337
:overlay-category 'category
:fringe-bitmap 'left-triangle
:fringe-face 'highlight
:error-list-face 'font-lock-constant-face)
(ert-deftest flycheck-define-error-level/is-error-level? ()
:tags '(error-level)
(should (flycheck-error-level-p 'test-level)))
(ert-deftest flycheck-define-error-level/has-severity ()
:tags '(error-level)
(should (= (flycheck-error-level-severity 'test-level) 1337)))
(ert-deftest flycheck-define-error-level/has-fringe-bitmap ()
:tags '(error-level)
(should (eq (flycheck-error-level-fringe-bitmap 'test-level) 'left-triangle)))
(ert-deftest flycheck-define-error-level/has-fringe-face ()
:tags '(error-level)
(should (eq (flycheck-error-level-fringe-face 'test-level) 'highlight)))
(ert-deftest flycheck-define-error-level/has-overlay-category ()
:tags '(error-level)
(should (eq (flycheck-error-level-overlay-category 'test-level) 'category)))
(ert-deftest flycheck-define-error-level/has-error-list-face ()
:tags '(error-level)
(should (eq (flycheck-error-level-error-list-face 'test-level)
'font-lock-constant-face)))
(ert-deftest flycheck-error-level-make-fringe-icon/has-fringe-bitmap ()
:tags '(error-level)
(pcase-let* ((icon (flycheck-error-level-make-fringe-icon
'test-level 'left-fringe))
(`(_ ,bitmap _) (get-text-property 0 'display icon)))
(should (eq bitmap 'left-triangle))))
(ert-deftest flycheck-error-level-make-fringe-icon/has-fringe-face ()
:tags '(error-level)
(pcase-let* ((icon (flycheck-error-level-make-fringe-icon 'test-level 'left-fringe))
(`(_ _ ,face) (get-text-property 0 'display icon)))
(should (eq face 'highlight))))
(ert-deftest flycheck-error-level-make-fringe-icon/left-fringe ()
:tags '(error-level)
(pcase-let* ((icon (flycheck-error-level-make-fringe-icon 'test-level 'left-fringe))
(`(,side _ _) (get-text-property 0 'display icon)))
(should (eq side 'left-fringe))))
(ert-deftest flycheck-error-level-make-fringe-icon/right-fringe ()
:tags '(error-level)
(pcase-let* ((icon (flycheck-error-level-make-fringe-icon 'test-level 'right-fringe))
(`(,side _ _) (get-text-property 0 'display icon)))
(should (eq side 'right-fringe))))
(ert-deftest flycheck-error-level-make-fringe-icon/invalid-side ()
:tags '(error-level)
(let ((err (should-error (flycheck-error-level-make-fringe-icon 'test-level
'up-fringe))))
(should (string= (cadr err) "Invalid fringe side: up-fringe"))))
;;; Built-in error levels
(ert-deftest flycheck-error-level-error ()
:tags '(error-level)
(should (= (flycheck-error-level-severity 'error) 100))
(should (eq (flycheck-error-level-fringe-bitmap 'error)
'flycheck-fringe-bitmap-double-arrow))
(should (eq (flycheck-error-level-fringe-face 'error)
'flycheck-fringe-error))
(should (eq (flycheck-error-level-overlay-category 'error)
'flycheck-error-overlay))
(should (eq (flycheck-error-level-error-list-face 'error)
'flycheck-error-list-error)))
(ert-deftest flycheck-error-level-warning ()
:tags '(error-level)
(should (= (flycheck-error-level-severity 'warning) 10))
(should (eq (flycheck-error-level-fringe-bitmap 'warning)
'flycheck-fringe-bitmap-double-arrow))
(should (eq (flycheck-error-level-fringe-face 'warning)
'flycheck-fringe-warning))
(should (eq (flycheck-error-level-overlay-category 'warning)
'flycheck-warning-overlay))
(should (eq (flycheck-error-level-error-list-face 'warning)
'flycheck-error-list-warning)))
(ert-deftest flycheck-error-level-info ()
:tags '(error-level)
(should (= (flycheck-error-level-severity 'info) -10))
(should (eq (flycheck-error-level-fringe-bitmap 'info)
'flycheck-fringe-bitmap-double-arrow))
(should (eq (flycheck-error-level-fringe-face 'info)
'flycheck-fringe-info))
(should (eq (flycheck-error-level-overlay-category 'info)
'flycheck-info-overlay))
(should (eq (flycheck-error-level-error-list-face 'info)
'flycheck-error-list-info)))
;;; Error analysis
(ert-deftest flycheck-has-max-errors-p ()
:tags '(error-analysis)
(should (flycheck-has-max-errors-p nil 'error))
(let ((errors (list (flycheck-error-new-at 10 10 'warning)
(flycheck-error-new-at 10 10 'info))))
(should (flycheck-has-max-errors-p errors 'error))
(should (flycheck-has-max-errors-p errors 'warning))
(should-not (flycheck-has-max-errors-p errors 'info))))
;;; Error overlays in the current buffer
(ert-deftest flycheck-info-overlay/priority ()
:tags '(overlay)
(should (= (get 'flycheck-info-overlay 'priority) 90)))
(ert-deftest flycheck-warning-overlay/priority ()
:tags '(overlay)
(should (= (get 'flycheck-warning-overlay 'priority) 100)))
(ert-deftest flycheck-error-overlay/priority ()
:tags '(overlay)
(should (= (get 'flycheck-error-overlay 'priority) 110)))
(ert-deftest flycheck-info-overlay/face ()
:tags '(overlay)
(should (eq (get 'flycheck-info-overlay 'face) 'flycheck-info)))
(ert-deftest flycheck-warning-overlay/face ()
:tags '(overlay)
(should (eq (get 'flycheck-warning-overlay 'face) 'flycheck-warning)))
(ert-deftest flycheck-error-overlay/face ()
:tags '(overlay)
(should (eq (get 'flycheck-error-overlay 'face) 'flycheck-error)))
(ert-deftest flycheck-add-overlay/undefined-error-level ()
:tags '(overlay)
(let ((err (should-error (flycheck-add-overlay
(flycheck-error-new-at 1 1 'foo)))))
(should (string= (cadr err) "Undefined error level: foo"))))
(ert-deftest flycheck-add-overlay/no-error-level ()
:tags '(overlay)
(let ((err (should-error (flycheck-add-overlay (flycheck-error-new-at 1 1)))))
(should (string= (cadr err) "Undefined error level: nil"))))
(ert-deftest flycheck-add-overlay/info-category ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Foo")
(let ((overlay (flycheck-add-overlay (flycheck-error-new-at 1 1 'info))))
(should (eq (overlay-get overlay 'category) 'flycheck-info-overlay)))))
(ert-deftest flycheck-add-overlay/warning-category ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Foo")
(let ((overlay (flycheck-add-overlay (flycheck-error-new-at 1 1 'warning))))
(should (eq (overlay-get overlay 'category) 'flycheck-warning-overlay)))))
(ert-deftest flycheck-add-overlay/error-category ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Foo")
(let ((overlay (flycheck-add-overlay (flycheck-error-new-at 1 1 'error))))
(should (eq (overlay-get overlay 'category) 'flycheck-error-overlay)))))
(ert-deftest flycheck-add-overlay/has-help-echo ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(let ((overlay (flycheck-add-overlay
(flycheck-error-new-at 1 1 'info "A bar message"))))
(should (eq (overlay-get overlay 'help-echo) #'flycheck-help-echo)))))
(ert-deftest flycheck-add-overlay/has-flycheck-overlay-property ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Foo bar")
(let* ((err (flycheck-error-new-at 1 1 'error))
(overlay (flycheck-add-overlay err)))
(should (overlay-get overlay 'flycheck-overlay)))))
(ert-deftest flycheck-add-overlay/has-flycheck-error-property ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Foo bar")
(let* ((err (flycheck-error-new-at 1 1 'warning))
(overlay (flycheck-add-overlay err)))
(should (eq (overlay-get overlay 'flycheck-error) err)))))
(ert-deftest flycheck-add-overlay/has-no-fringe-icon-with-disabled-indication ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World")
(let ((flycheck-indication-mode nil))
(dolist (level '(warning info error))
(let ((overlay (flycheck-add-overlay (flycheck-error-new-at 1 1 level))))
(should-not (overlay-get overlay 'before-string)))))))
(ert-deftest flycheck-add-overlay/has-info-fringe-icon ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World")
(pcase-let* ((overlay (flycheck-add-overlay
(flycheck-error-new-at 1 1 'info)))
(before-string (overlay-get overlay 'before-string))
(`(_ ,bitmap ,face) (get-text-property 0 'display before-string)))
(should (eq face 'flycheck-fringe-info))
(should (eq bitmap 'flycheck-fringe-bitmap-double-arrow)))))
(ert-deftest flycheck-add-overlay/has-warning-fringe-icon ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World")
(pcase-let* ((overlay (flycheck-add-overlay
(flycheck-error-new-at 1 1 'warning)))
(before-string (overlay-get overlay 'before-string))
(`(_ ,bitmap ,face) (get-text-property 0 'display before-string)))
(should (eq face 'flycheck-fringe-warning))
(should (eq bitmap 'flycheck-fringe-bitmap-double-arrow)))))
(ert-deftest flycheck-add-overlay/has-error-fringe-icon ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World")
(pcase-let* ((overlay (flycheck-add-overlay
(flycheck-error-new-at 1 1 'error)))
(before-string (overlay-get overlay 'before-string))
(`(_ ,bitmap ,face) (get-text-property 0 'display before-string)))
(should (eq face 'flycheck-fringe-error))
(should (eq bitmap 'flycheck-fringe-bitmap-double-arrow)))))
(ert-deftest flycheck-add-overlay/has-left-fringe-icon ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World")
;; Test the various indication modes
(let ((flycheck-indication-mode 'left-fringe))
(pcase-let* ((overlay (flycheck-add-overlay
(flycheck-error-new-at 1 1 'error)))
(before-string (overlay-get overlay 'before-string))
(`(,side _ _) (get-text-property 0 'display before-string)))
(should (eq side 'left-fringe))))))
(ert-deftest flycheck-add-overlay/has-right-fringe-icon ()
:tags '(overlay)
(flycheck-ert-with-temp-buffer
(insert "Hello\n World")
;; Test the various indication modes
(let ((flycheck-indication-mode 'right-fringe))
(pcase-let* ((overlay (flycheck-add-overlay
(flycheck-error-new-at 1 1 'error)))
(before-string (overlay-get overlay 'before-string))
(`(,side _ _) (get-text-property 0 'display before-string)))
(should (eq side 'right-fringe))))))
(ert-deftest flycheck-add-overlay/right-position-in-narrowed-buffer ()
:tags '(overlay language-emacs-lisp
checker-emacs-lisp checker-emacs-lisp-checkdoc)
"Test that all overlays are added at the right positions with narrowing in place."
(flycheck-ert-with-resource-buffer "narrowing.el"
(emacs-lisp-mode)
(flycheck-mode)
;; Narrow to the function and check the buffer
(re-search-forward "(defun .*")
(forward-line 1)
(narrow-to-defun)
(should (buffer-narrowed-p))
(flycheck-ert-buffer-sync)
;; We should have two errors highlighted between point min and max now
(should (= (length (flycheck-overlays-in (point-min) (point-max))) 2))
;; Remove restrictions and test that all errors are reported
(widen)
(should (= (length (flycheck-overlays-in (point-min) (point-max))) 4))
(flycheck-ert-should-errors
'(9 1 warning "`message' called with 0 args to fill 1 format field(s)"
:checker emacs-lisp)
'(11 8 warning "`message' called with 0 args to fill 1 format field(s)"
:checker emacs-lisp)
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc)
'(15 1 warning "`message' called with 0 args to fill 1 format field(s)"
:checker emacs-lisp))))
(ert-deftest flycheck-add-overlay/help-echo-is-error-message ()
:tags '(overlay)
"Check for default help at point."
(flycheck-ert-with-temp-buffer
(insert " ")
(goto-char 1)
(flycheck-add-overlay (flycheck-error-new-at 1 1 'info "A bar message"))
(should (string= (help-at-pt-string) "A bar message"))))
(ert-deftest flycheck-add-overlay/can-suppress-help-echo ()
:tags '(overlay)
"Check that setting help-echo function to nil removes help echoes."
(flycheck-ert-with-temp-buffer
(insert " ")
(goto-char 1)
(flycheck-add-overlay (flycheck-error-new-at 1 1 'info "info"))
(let ((flycheck-help-echo-function nil))
(should (string= (help-at-pt-string) nil)))))
(ert-deftest flycheck-add-overlay/help-echo-for-nil-message-is-default ()
:tags '(overlay)
"Check that null error messages are replaced by 'Unkown [level]'."
(flycheck-ert-with-temp-buffer
(insert " ")
(goto-char 1)
(flycheck-add-overlay (flycheck-error-new-at 1 1 'info))
(should (string= (help-at-pt-string) "Unknown info"))))
(ert-deftest flycheck-add-overlay/help-echo-stacks-errors ()
:tags '(overlay)
"Check that help-echo messages contain all error messages at point."
(flycheck-ert-with-temp-buffer
(insert " ")
(goto-char 1)
(flycheck-add-overlay (flycheck-error-new-at 1 1 'info "info"))
(flycheck-add-overlay (flycheck-error-new-at 1 1 'warning "warning"))
(flycheck-add-overlay (flycheck-error-new-at 1 1 'error "error"))
(should (string= (help-at-pt-string) "info\n\nwarning\n\nerror"))))
;;; Error navigation in the current buffer
(defmacro flycheck-test-with-nav-buffer (minimum-level &rest body)
"With MINIMUM-LEVEL, eval BODY in a temporary buffer for navigation.
Set `flycheck-navigation-minimum-level' to MINIMUM-LEVEL while
evaluating BODY."
(declare (indent 1))
`(flycheck-ert-with-resource-buffer "language/emacs-lisp/errors-and-warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
(when ,minimum-level
(let ((flycheck-navigation-minimum-level ,minimum-level))
(flycheck-ert-buffer-sync)
(goto-char (point-min))
,@body))))
(ert-deftest flycheck-next-error/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/goes-to-next-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(flycheck-next-error)
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/errors-beyond-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(let ((err (should-error (flycheck-next-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(flycheck-next-error 2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-next-error -2)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/reset-navigates-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-next-error 1 'reset)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/does-not-cross-narrowing ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(re-search-forward "(defun .*")
(narrow-to-defun)
(goto-char (point-min))
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 1))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/errors-before-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(let ((err (should-error (flycheck-previous-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/goes-to-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-previous-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-previous-error 2)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-previous-error/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(flycheck-previous-error -2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(let ((err (should-error (flycheck-previous-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-first-error/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-first-error/stays-at-first-error-if-called-again ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-first-error)
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-first-error/goes-to-second-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer nil
(goto-char (point-max))
(flycheck-first-error 2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-errors/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-errors/goes-to-next-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(flycheck-next-error)
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-errors/errors-beyond-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-errors/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(let ((err (should-error (flycheck-next-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-errors/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(let ((err (should-error (flycheck-next-error 2) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-errors/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(let ((err (should-error (flycheck-next-error -2) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-errors/reset-navigates-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(flycheck-next-error 1 'reset)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-errors/does-not-cross-narrowing ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(re-search-forward "(defun .*")
(narrow-to-defun)
(goto-char (point-min))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-errors/errors-before-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(let ((err (should-error (flycheck-previous-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-errors/goes-to-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(flycheck-previous-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/over-errors/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(let ((err (should-error (flycheck-previous-error -2) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-errors/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(let ((err (should-error (flycheck-previous-error -2) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-errors/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(let ((err (should-error (flycheck-previous-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-first-error/over-errors/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-first-error/over-errors/stays-at-first-error-if-called-again ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(flycheck-first-error)
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 2)))) ; second occurrence is an 'error
(ert-deftest flycheck-first-error/over-errors/goes-to-second-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'error
(goto-char (point-max))
(let ((err (should-error (flycheck-first-error 2) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-warnings/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/over-warnings/goes-to-next-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(flycheck-next-error)
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-warnings/errors-beyond-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-warnings/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(let ((err (should-error (flycheck-next-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-warnings/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(let ((err (should-error (flycheck-next-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-warnings/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-next-error -2)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/over-warnings/reset-navigates-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-next-error 1 'reset)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/over-warnings/does-not-cross-narrowing ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(re-search-forward "(defun .*")
(narrow-to-defun)
(goto-char (point-min))
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 1))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-warnings/errors-before-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(let ((err (should-error (flycheck-previous-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-warnings/goes-to-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-previous-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/over-warnings/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-previous-error 2)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-previous-error/over-warnings/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(flycheck-previous-error -2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/over-warnings/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(let ((err (should-error (flycheck-previous-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-first-error/over-warnings/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-first-error/over-warnings/stays-at-first-error-if-called-again ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-first-error)
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-first-error/over-warnings/goes-to-second-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-first-error 2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-informational/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/over-informational/goes-to-next-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(flycheck-next-error)
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-informational/errors-beyond-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-informational/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(let ((err (should-error (flycheck-next-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-next-error/over-informational/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(flycheck-next-error 2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-next-error/over-informational/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-next-error -2)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/over-informational/reset-navigates-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-next-error 1 'reset)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-next-error/over-informational/does-not-cross-narrowing ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(re-search-forward "(defun .*")
(narrow-to-defun)
(goto-char (point-min))
(flycheck-next-error)
(should (flycheck-ert-at-nth-error 1))
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-informational/errors-before-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(let ((err (should-error (flycheck-previous-error) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-previous-error/over-informational/goes-to-last-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-previous-error)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/over-informational/navigate-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-previous-error 2)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-previous-error/over-informational/navigate-back-by-two-errors ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(flycheck-previous-error -2)
(should (flycheck-ert-at-nth-error 2))))
(ert-deftest flycheck-previous-error/over-informational/errors-when-moving-too-far ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(let ((err (should-error (flycheck-previous-error 4) :type 'user-error)))
(should (string= (cadr err) "No more Flycheck errors")))))
(ert-deftest flycheck-first-error/over-informational/goes-to-first-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-first-error/over-informational/stays-at-first-error-if-called-again ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-first-error)
(flycheck-first-error)
(should (flycheck-ert-at-nth-error 1))))
(ert-deftest flycheck-first-error/over-informational/goes-to-second-error ()
:tags '(navigation)
(flycheck-test-with-nav-buffer 'info
(goto-char (point-max))
(flycheck-first-error 2)
(should (flycheck-ert-at-nth-error 2))))
;;; Displaying errors in buffers
(ert-deftest flycheck-display-errors/no-display-function-set ()
:tags '(error-display)
(let ((err (flycheck-error-new-at 10 20 'warning "This is a Flycheck error."))
(flycheck-display-errors-function nil))
(shut-up
;; Without an error function, error display should be a no-op.
(flycheck-display-errors (list err))
(should (equal (shut-up-current-output) "")))))
(ert-deftest flycheck-display-errors/custom-function ()
:tags '(error-display)
(let* ((err (flycheck-error-new-at 10 20 'warning "Foo"))
(displayed-errors nil)
(flycheck-display-errors-function (lambda (errors)
(dolist (err errors)
(push err displayed-errors)))))
(flycheck-display-errors (list err))
(should (equal displayed-errors (list err)))))
;;; Functions to display errors
(ert-deftest flycheck-display-error-messages ()
:tags '(error-display)
(let ((err (flycheck-error-new-at 10 20 'warning
"This is a Flycheck error."
:id "spam")))
(shut-up
(flycheck-display-error-messages (list err))
(should (equal (shut-up-current-output)
"This is a Flycheck error. [spam]\n")))))
;;; Working with errors
(ert-deftest flycheck-copy-errors-as-kill ()
:tags '(errors-at-point)
(flycheck-ert-with-temp-buffer
(insert "A test buffer to copy errors from")
(let ((flycheck-highlighting-mode 'columns) ; Disable Sexps parsing
(errors (list (flycheck-error-new-at 1 nil 'error "1st message")
(flycheck-error-new-at 1 10 'warning "2nd message"
:id "foo"))))
(mapc #'flycheck-add-overlay errors)
(flycheck-copy-errors-as-kill 10)
(should (equal (-take 2 kill-ring) '("1st message" "2nd message")))
(flycheck-copy-errors-as-kill 10 #'flycheck-error-id)
(should (equal (-take 1 kill-ring) '("foo")))
(flycheck-copy-errors-as-kill 10 #'flycheck-error-format-message-and-id)
(should (equal (-take 2 kill-ring)
'("1st message" "2nd message [foo]"))))))
;;; Syntax checkers using external commands
(ert-deftest flycheck-command-argument-p/with-symbols ()
:tags '(definition)
(dolist (symbol '(source
source-inplace
source-original
temporary-directory
temporary-file-name
null-device))
(should (flycheck-command-argument-p symbol))))
(ert-deftest flycheck-command-argument-p/config-file-with-variable-symbol ()
:tags '(definition)
(should (flycheck-command-argument-p '(config-file "foo" bar))))
(ert-deftest flycheck-command-argument-p/config-file-with-quoted-variable-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(config-file "foo" 'bar))))
(ert-deftest flycheck-command-argument-p/config-file-without-variable-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(config-file "foo"))))
(ert-deftest flycheck-command-argument-p/option-without-filter ()
:tags '(definition)
(should (flycheck-command-argument-p '(option "foo" bar))))
(ert-deftest flycheck-command-argument-p/option-with-filter ()
:tags '(definition)
(should (flycheck-command-argument-p '(option "foo" bar filter))))
(ert-deftest flycheck-command-argument-p/option-with-quoted-variable-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option "foo" 'bar))))
(ert-deftest flycheck-command-argument-p/option-with-quoted-filter-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option "foo" bar 'filter))))
(ert-deftest flycheck-command-argument-p/option-without-variable ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option "foo"))))
(ert-deftest flycheck-command-argument-p/option-list-without-filter-and-prepender ()
:tags '(definition)
(should (flycheck-command-argument-p '(option-list "foo" bar))))
(ert-deftest flycheck-command-argument-p/option-list-with-prepender ()
:tags '(definition)
(should (flycheck-command-argument-p '(option-list "foo" bar prepend-fn))))
(ert-deftest flycheck-command-argument-p/option-list-with-prepender-and-filter ()
:tags '(definition)
(should (flycheck-command-argument-p '(option-list "foo" bar prepend-fn filter))))
(ert-deftest flycheck-command-argument-p/option-list-with-quoted-variable-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option-list "foo" 'bar))))
(ert-deftest flycheck-command-argument-p/option-list-with-quoted-prepender-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option-list "foo" bar 'prepend-fn))))
(ert-deftest flycheck-command-argument-p/option-list-with-quoted-filter-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option-list "foo" bar prepend-fn 'filter))))
(ert-deftest flycheck-command-argument-p/option-list-without-variable-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(option-list "foo"))))
(ert-deftest flycheck-command-argument-p/eval-with-variable ()
:tags '(definition)
(should (flycheck-command-argument-p '(eval bar))))
(ert-deftest flycheck-command-argument-p/eval-with-function-call ()
:tags '(definition)
(should (flycheck-command-argument-p '(eval (spam "with eggs")))))
(ert-deftest flycheck-command-argument-p/eval-with-no-form ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(eval))))
(ert-deftest flycheck-command-argument-p/eval-with-multiple-forms ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(eval foo bar))))
(ert-deftest flycheck-command-argument-p/integer-literal ()
:tags '(definition)
(should-not (flycheck-command-argument-p 100)))
(ert-deftest flycheck-command-argument-p/unknown-argument-symbol ()
:tags '(definition)
(should-not (flycheck-command-argument-p 'foo)))
(ert-deftest flycheck-command-argument-p/unknown-argument-cell ()
:tags '(definition)
(should-not (flycheck-command-argument-p '(foo bar))))
(ert-deftest flycheck-start-command-checker/wraps-command ()
:tags '(command-checker)
(let* ((was-called 0)
(flycheck-command-wrapper-function (lambda (cmd)
(cl-incf was-called)
(cons "echo" cmd))))
;; Since we just `echo' the command, there should be zero errors
(flycheck-ert-should-syntax-check
"language/emacs-lisp/warnings.el" 'emacs-lisp-mode)
;; Called once for `emacs-lisp', and a second time for checkdoc
(should (equal was-called 2))))
;;; Executables of command checkers
(ert-deftest flycheck-overridden-executable ()
:tags '(executables language-emacs-lisp
checker-emacs-lisp checker-emacs-lisp-checkdoc)
(let ((flycheck-emacs-lisp-executable (flycheck-ert-resource-filename
"bin/dummy-emacs")))
(flycheck-ert-should-syntax-check
"language/emacs-lisp/warnings.el" 'emacs-lisp-mode
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc)
'(17 4 error "t is not true!" :checker emacs-lisp)
'(19 11 warning "This is a stupid message" :checker emacs-lisp))))
(ert-deftest flycheck-set-checker-executable/real-executable ()
:tags '(executables)
(flycheck-ert-with-temp-buffer
;; Create a temporary buffer to restrict the scope of
;; `flycheck-emacs-lisp-executable'
(let ((file-name (flycheck-ert-resource-filename "bin/dummy-emacs")))
(should (file-exists-p file-name))
(should (file-executable-p file-name))
(should-not (local-variable-p 'flycheck-emacs-lisp-executable))
(with-no-warnings
(flycheck-set-checker-executable 'emacs-lisp file-name))
(should (local-variable-p 'flycheck-emacs-lisp-executable))
(should (string= flycheck-emacs-lisp-executable file-name))))
;; The global value should remain unaffected
(should-not flycheck-emacs-lisp-executable))
(ert-deftest flycheck-set-checker-executable/no-executable-given ()
:tags '(executables)
(flycheck-ert-with-temp-buffer
(let ((file-name (flycheck-ert-resource-filename "bin/dummy-emacs")))
(setq-local flycheck-emacs-lisp-executable file-name)
(should (string= flycheck-emacs-lisp-executable file-name))
(with-no-warnings
(flycheck-set-checker-executable 'emacs-lisp))
(should-not flycheck-emacs-lisp-executable)
(should (local-variable-p 'flycheck-emacs-lisp-executable)))))
(ert-deftest flycheck-set-checker-executable/executable-is-nil ()
:tags '(executables)
(flycheck-ert-with-temp-buffer
(let ((file-name (flycheck-ert-resource-filename "bin/dummy-emacs")))
(setq-local flycheck-emacs-lisp-executable file-name)
(should (string= flycheck-emacs-lisp-executable file-name))
(with-no-warnings
(flycheck-set-checker-executable 'emacs-lisp nil))
(should-not flycheck-emacs-lisp-executable)
(should (local-variable-p 'flycheck-emacs-lisp-executable)))))
(ert-deftest flycheck-set-checker-executable/non-existing-file ()
:tags '(executables)
(let ((file-name (flycheck-ert-resource-filename "no-such-file")))
(should-not (file-exists-p file-name))
(let ((err (should-error (flycheck-set-checker-executable
'emacs-lisp file-name) :type 'user-error)))
(should (string= (cadr err) (format "%s is no executable" file-name))))))
(ert-deftest flycheck-set-checker-executable/file-not-executable ()
:tags '(executables)
(let ((file-name (flycheck-ert-resource-filename "language/emacs-lisp/warnings.el")))
(should (file-exists-p file-name))
(should-not (file-executable-p file-name))
(let ((err (should-error (flycheck-set-checker-executable
'emacs-lisp file-name) :type 'user-error)))
(should (string= (cadr err) (format "%s is no executable" file-name))))))
;;; Configuration files and options for command syntax checkers
(ert-deftest flycheck-locate-config-file-by-path/just-a-base-name ()
:tags '(configuration)
(flycheck-ert-with-temp-buffer
(cd flycheck-test-directory)
(should-not (flycheck-locate-config-file-by-path "flycheck-test.el"
'emacs-lisp))))
(ert-deftest flycheck-locate-config-file-by-path/with-path ()
:tags '(configuration)
(flycheck-ert-with-temp-buffer
(cd flycheck-test-directory)
(should (equal (flycheck-locate-config-file-by-path "../Makefile"
'emacs-lisp)
(expand-file-name "../Makefile" flycheck-test-directory)))))
(ert-deftest flycheck-locate-config-file-by-path/non-existing-file ()
:tags '(configuration)
(flycheck-ert-with-temp-buffer
(cd flycheck-test-directory)
(should-not (flycheck-locate-config-file-by-path "../foobar" 'emacs-lisp))))
(ert-deftest flycheck-locate-config-file-ancestor-directories/not-existing-file ()
:tags '(configuration)
(flycheck-ert-with-temp-buffer
(setq buffer-file-name (expand-file-name "flycheck-test.el"
flycheck-test-directory))
(should-not (flycheck-locate-config-file-ancestor-directories
"foo" 'emacs-lisp))))
(ert-deftest flycheck-locate-config-file-ancestor-directories/file-on-same-level ()
:tags '(configuration)
(flycheck-ert-with-temp-buffer
(setq buffer-file-name (expand-file-name "flycheck-test.el"
flycheck-test-directory))
(should (equal (flycheck-locate-config-file-ancestor-directories
"run.el" 'emacs-lisp)
(expand-file-name "run.el" flycheck-test-directory)))))
(ert-deftest flycheck-locate-config-file-ancestor-directories/file-on-parent-level ()
:tags '(configuration)
(flycheck-ert-with-temp-buffer
(setq buffer-file-name (expand-file-name "flycheck-test.el"
flycheck-test-directory))
(should (equal (flycheck-locate-config-file-ancestor-directories
"Makefile" 'emacs-lisp)
(expand-file-name "../Makefile"
flycheck-test-directory)))))
(ert-deftest flycheck-locate-config-file/not-existing-file ()
:tags '(configuration)
(flycheck-ert-with-env (list (cons "HOME" flycheck-test-directory))
(should-not (flycheck-locate-config-file-home "foo" 'emacs-lisp))))
(ert-deftest flycheck-locate-config-file/existing-file-in-parent-directory ()
:tags '(configuration)
(flycheck-ert-with-env (list (cons "HOME" flycheck-test-directory))
(should-not (flycheck-locate-config-file-home "Makefile" 'emacs-lisp))))
(ert-deftest flycheck-locate-config-file/existing-file-in-home-directory ()
:tags '(configuration)
(flycheck-ert-with-env (list (cons "HOME" flycheck-test-directory))
(should (equal (flycheck-locate-config-file-home
"flycheck-test.el" 'emacs-lisp)
(expand-file-name "flycheck-test.el"
flycheck-test-directory)))))
(ert-deftest flycheck-option-int/pass-through-nil ()
:tags '(option-filters)
(should (null (flycheck-option-int nil))))
(ert-deftest flycheck-option-int/integer-argument ()
:tags '(option-filters)
(should (equal (flycheck-option-int 10) "10")))
(ert-deftest flycheck-option-comma-separated-list/empty-list ()
:tags '(option-filters)
(should (null (flycheck-option-comma-separated-list nil))))
(ert-deftest flycheck-option-comma-separated-list/with-single-nil ()
:tags '(option-filters)
(should (null (flycheck-option-comma-separated-list '(nil)))))
(ert-deftest flycheck-option-comma-separated-list/filter-returns-nil ()
:tags '(option-filters)
(should (null (flycheck-option-comma-separated-list '(10 20) nil
(lambda (_x) nil)))))
(ert-deftest flycheck-option-comma-separated-list/default-separator ()
:tags '(option-filters)
(should (equal (flycheck-option-comma-separated-list '("foo" "bar"))
"foo,bar")))
(ert-deftest flycheck-option-comma-separated-list/custom-separator ()
:tags '(option-filters)
(should (equal (flycheck-option-comma-separated-list '("foo" "bar") ":")
"foo:bar")))
(ert-deftest flycheck-option-comma-separated-list/custom-filter ()
:tags '(option-filters)
(should (equal (flycheck-option-comma-separated-list '(10 20) nil
#'number-to-string)
"10,20")))
;;; Built-in checkers
;; Tell the byte compiler about the variables we'll use
(defvar js2-mode-show-strict-warnings)
(defvar js2-mode-show-parse-errors)
(defvar js3-mode-show-parse-errors)
(defvar python-indent-guess-indent-offset)
(flycheck-ert-def-checker-test ada-gnat ada syntax-error
(flycheck-ert-should-syntax-check
"language/ada/syntaxerror.adb" 'ada-mode
'(7 32 error "missing \";\"" :checker ada-gnat)
'(8 5 error "misspelling of \"SYNTAXERROR\"" :checker ada-gnat)))
(flycheck-ert-def-checker-test ada-gnat ada warnings
(flycheck-ert-should-syntax-check
"language/ada/hello.adb" 'ada-mode
'( 6 4 warning "variable \"Name\" is not referenced" :checker ada-gnat)
'(8 11 warning "unrecognized pragma \"Foo\"" :checker ada-gnat)))
(flycheck-ert-def-checker-test asciidoc asciidoc nil
(let ((flycheck-disabled-checkers '(asciidoctor)))
(flycheck-ert-should-syntax-check
"language/asciidoc.adoc" 'adoc-mode
'(1 nil warning "missing style: [paradef-default]: paragraph" :checker asciidoc)
'(3 nil info "old tables syntax" :checker asciidoc)
'(11 nil error "[tabledef-default] illegal width=%60%" :checker asciidoc))))
(flycheck-ert-def-checker-test asciidoctor asciidoc nil
(flycheck-ert-should-syntax-check
"language/asciidoctor.adoc" 'adoc-mode
'(4 nil warning "section title out of sequence: expected level 1, got level 2" :checker asciidoctor)
'(6 nil error "unmatched macro: endif::[]" :checker asciidoctor)))
(flycheck-ert-def-checker-test c/c++-clang (c c++) error
(let ((flycheck-disabled-checkers '(c/c++-gcc)))
(flycheck-ert-should-syntax-check
"language/c_c++/error.cpp" 'c++-mode
'(2 20 error "no member named 'bar' in 'A'"
:checker c/c++-clang)
'(6 19 info "in instantiation of function template specialization 'foo<A>' requested here"
:checker c/c++-clang))))
(flycheck-ert-def-checker-test c/c++-clang (c c++) fatal-error
(let ((flycheck-disabled-checkers '(c/c++-gcc)))
(flycheck-ert-should-syntax-check
"language/c_c++/includes.c" 'c-mode
'(2 10 error "'library.h' file not found"
:checker c/c++-clang))))
(flycheck-ert-def-checker-test c/c++-clang (c c++) warnings
(let ((flycheck-disabled-checkers '(c/c++-gcc c/c++-cppcheck)))
(flycheck-ert-should-syntax-check
"language/c_c++/warning.c" 'c-mode
'(5 10 warning "unused variable 'unused'" :checker c/c++-clang)
'(7 15 warning "comparison of integers of different signs: 'int' and 'unsigned int'"
:checker c/c++-clang)
'(8 7 warning "no message" :checker c/c++-clang))))
(flycheck-ert-def-checker-test c/c++-clang (c c++) included-file-error
(let ((flycheck-clang-include-path '("./include"))
(flycheck-disabled-checkers '(c/c++-gcc)))
(flycheck-ert-should-syntax-check
"language/c_c++/in-included-file.cpp" 'c++-mode
`(3 nil warning "In include ./warning.c" :checker c/c++-clang))))
(flycheck-ert-def-checker-test c/c++-gcc (c c++) error
(let ((flycheck-disabled-checkers '(c/c++-clang)))
(flycheck-ert-should-syntax-check
"language/c_c++/error.cpp" 'c++-mode
'(2 20 error "'struct A' has no member named 'bar'"
:checker c/c++-gcc))))
(flycheck-ert-def-checker-test c/c++-gcc (c c++) fatal-error
(let ((flycheck-disabled-checkers '(c/c++-clang)))
(flycheck-ert-should-syntax-check
"language/c_c++/includes.c" 'c-mode
'(2 21 error "library.h: No such file or directory"
:checker c/c++-gcc))))
(flycheck-ert-def-checker-test c/c++-gcc (c c++) warning
(let ((flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck)))
(flycheck-ert-should-syntax-check
"language/c_c++/warning.c" 'c-mode
'(5 10 warning "unused variable 'unused'"
:id "-Wunused-variable" :checker c/c++-gcc)
'(7 15 warning "comparison between signed and unsigned integer expressions"
:id "-Wsign-compare" :checker c/c++-gcc)
'(8 7 warning "#warning" :id "-Wcpp" :checker c/c++-gcc))))
(flycheck-ert-def-checker-test c/c++-gcc (c c++) included-file-error
(let ((flycheck-gcc-include-path '("./include"))
(flycheck-disabled-checkers '(c/c++-clang)))
(flycheck-ert-should-syntax-check
"language/c_c++/in-included-file.cpp" 'c++-mode
`(3 nil warning "In include warning.c" :checker c/c++-gcc))))
(flycheck-ert-def-checker-test c/c++-cppcheck (c c++) nil
:tags '(cppcheck-xml)
(let ((flycheck-disabled-checkers '(c/c++-clang c/c++-gcc))
(flycheck-cppcheck-inconclusive nil)
(flycheck-cppcheck-checks '("style")))
(flycheck-ert-should-syntax-check
"language/c_c++/style2.cpp" 'c++-mode
'(3 nil info "The scope of the variable 'i' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\nvoid f(int x)\n{\n int i = 0;\n if (x) {\n // it's safe to move 'int i = 0;' here\n for (int n = 0; n < 10; ++n) {\n // it is possible but not safe to move 'int i = 0;' here\n do_something(&i);\n }\n }\n}\nWhen you see this message it is always safe to reduce the variable scope 1 level."
:id "variableScope" :checker c/c++-cppcheck))
(flycheck-ert-should-syntax-check
"language/c_c++/style.cpp" 'c-mode
'(5 nil info "Unused variable: unused" :id "unusedVariable"
:checker c/c++-cppcheck)
'(9 nil error "Division by zero." :id "zerodiv" :checker c/c++-cppcheck))
(flycheck-ert-should-syntax-check
"language/c_c++/style.cpp" 'c++-mode
'(5 nil info "Unused variable: unused" :id "unusedVariable"
:checker c/c++-cppcheck)
'(9 nil error "Division by zero." :id "zerodiv" :checker c/c++-cppcheck)
'(12 nil warning "Parameter 'foo' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++."
:id "passedByValue" :checker c/c++-cppcheck))))
(flycheck-ert-def-checker-test cfengine cfengine error
(skip-unless (fboundp 'cfengine3-mode))
(flycheck-ert-should-syntax-check
"language/cfengine/error.cf" 'cfengine3-mode
'(8 20 error "Unknown promise type 'nosuchpromisetype'" :checker cfengine)))
(flycheck-ert-def-checker-test cfengine cfengine warning
(skip-unless (fboundp 'cfengine3-mode))
(flycheck-ert-should-syntax-check
"language/cfengine/warning.cf" 'cfengine3-mode
'(3 34 warning "Removed constraint 'host_licenses_paid' in promise type 'common' [-Wremoved]"
:checker cfengine)))
(flycheck-ert-def-checker-test chef-foodcritic chef nil
(flycheck-ert-should-syntax-check
"language/chef/recipes/error.rb" 'ruby-mode
'(3 nil error "FC002: Avoid string interpolation where not required"
:checker chef-foodcritic)
'(11 nil error "FC004: Use a service resource to start and stop services"
:checker chef-foodcritic)))
(flycheck-ert-def-checker-test coffee coffee syntax-error
(flycheck-ert-should-syntax-check
"language/coffee/syntax-error.coffee" 'coffee-mode
'(4 7 error "missing \"" :checker coffee)))
(flycheck-ert-def-checker-test coffee-coffeelint coffee error
:tags '(checkstyle-xml)
(flycheck-ert-should-syntax-check
"language/coffee/error.coffee" 'coffee-mode
'(4 nil error "Throwing strings is forbidden; context:"
:checker coffee-coffeelint)))
(flycheck-ert-def-checker-test coffee-coffeelint coffee warning
:tags '(checkstyle-xml)
(let ((flycheck-coffeelintrc "lint.json"))
(flycheck-ert-should-syntax-check
"language/coffee/error.coffee" 'coffee-mode
'(4 nil warning "Throwing strings is forbidden; context:"
:checker coffee-coffeelint))))
(flycheck-ert-def-checker-test coq coq syntax-error
(skip-unless (load "gallina" 'noerror 'nomessage))
(flycheck-ert-should-syntax-check
"language/coq/syntax-error.v" 'coq-mode
'(6 10 error "\"end\" expected after [branches] (in [match_constr])."
:checker coq)))
(flycheck-ert-def-checker-test coq coq error
(skip-unless (load "gallina" 'noerror 'nomessage))
(flycheck-ert-should-syntax-check
"language/coq/error.v" 'coq-mode
'(7 21 error "In environment
evenb : nat -> bool
n : nat
n0 : nat
n' : nat
The term \"1\" has type \"nat\" while it is expected to have type \"bool\"." :checker coq)))
(flycheck-ert-def-checker-test css-csslint css nil
:tags '(checkstyle-xml)
(flycheck-ert-should-syntax-check
"language/css/warning.css" 'css-mode
'(3 6 warning "Heading (h1) should not be qualified."
:id "Disallowqualifiedheadings" :checker css-csslint)))
(flycheck-ert-def-checker-test css-csslint css syntax-error
:tags '(checkstyle-xml)
(flycheck-ert-should-syntax-check
"language/css/syntax-error.css" 'css-mode
'(4 14 error "Expected a `FUNCTION` or `IDENT` after colon at line 4, col 14."
:id "ParsingErrors" :checker css-csslint)))
(ert-deftest flycheck-d-module-re/matches-module-name ()
:tags '(language-d)
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(let ((s "module spam.with.eggs ;"))
(should (string-match flycheck-d-module-re s))
(should (string= "spam.with.eggs" (match-string 1 s)))))
(ert-deftest flycheck-d-base-directory/no-module-declaration ()
:tags '(language-d)
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(flycheck-ert-with-resource-buffer "language/d/src/dmd/no_module.d"
(should (flycheck-same-files-p
(flycheck-d-base-directory)
(flycheck-ert-resource-filename "language/d/src/dmd")))))
(ert-deftest flycheck-d-base-directory/with-module-declaration ()
:tags '(language-d)
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(flycheck-ert-with-resource-buffer "language/d/src/dmd/warning.d"
(should (flycheck-same-files-p
(flycheck-d-base-directory)
(flycheck-ert-resource-filename "language/d/src")))))
(ert-deftest flycheck-d-base-directory/package-file ()
:tags '(language-d)
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(flycheck-ert-with-resource-buffer "language/d/src/dmd/package.d"
(should (flycheck-same-files-p
(flycheck-d-base-directory)
(flycheck-ert-resource-filename "language/d/src")))))
(flycheck-ert-def-checker-test d-dmd d warning-include-path
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(let ((flycheck-dmd-include-path '("../../lib")))
(flycheck-ert-should-syntax-check
"language/d/src/dmd/warning.d" 'd-mode
'(9 5 warning "statement is not reachable" :checker d-dmd)
'(20 17 warning "function dmd.warning.bar is deprecated"
:checker d-dmd))))
(flycheck-ert-def-checker-test d-dmd d missing-import
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(flycheck-ert-should-syntax-check
"language/d/src/dmd/warning.d" 'd-mode
'(4 8 error "module external_library is in file 'external_library.d' which cannot be read"
:checker d-dmd)))
(flycheck-ert-def-checker-test d-dmd d continuation-line
(unless (version<= "24.4" emacs-version)
(ert-skip "Skipped because CC Mode is broken on 24.3.
See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
(flycheck-ert-should-syntax-check
"language/d/src/dmd/continuation.d" 'd-mode
'(5 12 error "undefined identifier 'invalid'"
:checker d-dmd)
'(10 12 error "template instance continuation.T!() error instantiating"
:checker d-dmd)
'(13 1 info "instantiated from here: U!()"
:checker d-dmd)))
(flycheck-ert-def-checker-test dockerfile-hadolint dockerfile error
(flycheck-ert-should-syntax-check
"language/dockerfile/Dockerfile.error" 'dockerfile-mode
'(2 1 error "unexpected 'I' expecting space, \"\\t\", \"ONBUILD\", \"FROM\", \"COPY\", \"RUN\", \"WORKDIR\", \"ENTRYPOINT\", \"VOLUME\", \"EXPOSE\", \"ENV\", \"ARG\", \"USER\", \"LABEL\", \"STOPSIGNAL\", \"CMD\", \"SHELL\", \"MAINTAINER\", \"ADD\", \"#\", \"HEALTHCHECK\" or end of input"
:id nil :checker dockerfile-hadolint)))
(flycheck-ert-def-checker-test dockerfile-hadolint dockerfile warnings
(flycheck-ert-should-syntax-check
"language/dockerfile/Dockerfile.warning" 'dockerfile-mode
'(1 nil warning "Always tag the version of an image explicitly."
:id "DL3006" :checker dockerfile-hadolint)
'(2 nil warning "Do not use apt-get upgrade or dist-upgrade."
:id "DL3005" :checker dockerfile-hadolint)
'(2 nil warning "Delete the apt-get lists after installing something"
:id "DL3009" :checker dockerfile-hadolint)
'(3 nil warning "Use absolute WORKDIR"
:id "DL3000" :checker dockerfile-hadolint)))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp nil
(flycheck-ert-should-syntax-check
"language/emacs-lisp/warnings.el" 'emacs-lisp-mode
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc)
'(16 6 warning "message called with 0 arguments, but requires 1+"
:checker emacs-lisp)
'(21 1 warning "the function `dummy-package-foo' is not known to be defined."
:checker emacs-lisp )))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp
uses-right-major-mode
(flycheck-ert-should-syntax-check
"language/emacs-lisp/checkdoc-elisp-mode-regression.el" 'emacs-lisp-mode
'(11 nil warning "All variables and subroutines might as well have a documentation string"
:checker emacs-lisp-checkdoc)))
(flycheck-ert-def-checker-test (emacs-lisp-checkdoc) emacs-lisp
inherits-checkdoc-variables
;; This test doesn't run on 24.3 and earlier because the corresponding
;; checkdoc variables were only introduced in 24.4.
(skip-unless (version<= "24.4" emacs-version))
(flycheck-ert-should-syntax-check
"language/emacs-lisp/local-checkdoc-variables.el" 'emacs-lisp-mode))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp
checks-compressed-file
(flycheck-ert-should-syntax-check
"language/emacs-lisp/compressed.el.gz" 'emacs-lisp-mode
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc)
'(16 6 warning "message called with 0 arguments, but requires 1+"
:checker emacs-lisp)
'(21 1 warning "the function `dummy-package-foo' is not known to be defined."
:checker emacs-lisp)))
(flycheck-ert-def-checker-test emacs-lisp emacs-lisp syntax-error
(let ((flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
(flycheck-ert-should-syntax-check
"language/emacs-lisp/syntax-error.el" 'emacs-lisp-mode
'(3 1 error "End of file during parsing" :checker emacs-lisp))))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp
without-file-name
;; Regression test for checkdoc in buffers without file names. See
;; https://github.com/flycheck/flycheck/issues/73 and
;; https://github.com/bbatsov/prelude/issues/259
(flycheck-ert-with-resource-buffer "language/emacs-lisp/warnings.el"
(set-visited-file-name nil 'no-query)
(emacs-lisp-mode)
(should-not (buffer-file-name))
(flycheck-ert-buffer-sync)
;; TODO: Consider whether checkdoc is really useful in buffers without file
;; names…
(should flycheck-current-errors)))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp
does-not-check-autoloads-buffers
;; Regression test ensuring that Emacs Lisp won't check autoload buffers.
;; These buffers are temporary buffers created during package installation to
;; collect the autoloads of newly installed packages before writing the
;; autoloads file. See `https://github.com/flycheck/flycheck/issues/45' and
;; `https://github.com/bbatsov/prelude/issues/253' for details.
(flycheck-ert-with-file-buffer (locate-library "shut-up-autoloads")
(should-not (flycheck-may-use-checker 'emacs-lisp))
(should-not (flycheck-may-use-checker 'emacs-lisp-checkdoc))))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp
checkdoc-does-not-check-cask-files
(flycheck-ert-with-file-buffer
(expand-file-name "Cask" flycheck-test-source-directory)
(should-not (flycheck-may-use-checker 'emacs-lisp-checkdoc))))
(flycheck-ert-def-checker-test (emacs-lisp emacs-lisp-checkdoc) emacs-lisp
does-not-check-with-no-byte-compile
;; We need to use a hook here, because `no-byte-compile' seems to be
;; explicitly changed when loading Emacs Lisp files
(let ((disable-byte-comp (lambda () (setq-local no-byte-compile t))))
(add-hook 'emacs-lisp-mode-hook disable-byte-comp)
(unwind-protect
(flycheck-ert-should-syntax-check
"language/emacs-lisp/warnings.el" 'emacs-lisp-mode
'(12 nil warning "First sentence should end with punctuation"
:checker emacs-lisp-checkdoc))
(remove-hook 'emacs-lisp-mode-hook disable-byte-comp))))
(flycheck-ert-def-checker-test emacs-lisp emacs-lisp check-declare-warnings
(let ((flycheck-emacs-lisp-check-declare t))
(flycheck-ert-should-syntax-check
"language/emacs-lisp/check-declare-warnings.el" 'emacs-lisp-mode
(if (version< emacs-version "25")
'(0 nil warning "`this-function-is-not-declared' was defined in this-file-does-not-exist.el: file not found"
:checker emacs-lisp)
'(9 1 warning "`this-function-is-not-declared' was defined in this-file-does-not-exist.el: file not found"
:checker emacs-lisp)))))
(flycheck-ert-def-checker-test emacs-lisp emacs-lisp disable-check-declare
(let ((flycheck-emacs-lisp-check-declare nil))
(flycheck-ert-should-syntax-check
"language/emacs-lisp/check-declare-warnings.el" 'emacs-lisp-mode)))
(flycheck-ert-def-checker-test erlang erlang error
(flycheck-ert-should-syntax-check
"language/erlang/erlang/error.erl" 'erlang-mode
'(7 nil error "head mismatch" :checker erlang)))
(flycheck-ert-def-checker-test erlang erlang warning
(flycheck-ert-should-syntax-check
"language/erlang/erlang/warning.erl" 'erlang-mode
'(6 nil warning "wrong number of arguments in format call" :checker erlang)))
(flycheck-ert-def-checker-test erlang-rebar3 erlang error
(flycheck-ert-should-syntax-check
"language/erlang/rebar3/src/erlang-error.erl" 'erlang-mode
'(7 nil error "head mismatch" :checker erlang-rebar3)))
(flycheck-ert-def-checker-test erlang-rebar3 erlang warning
(flycheck-ert-should-syntax-check
"language/erlang/rebar3/src/erlang-warning.erl" 'erlang-mode
'(6 nil warning "wrong number of arguments in format call" :checker erlang-rebar3)))
(flycheck-ert-def-checker-test erlang-rebar3 erlang build
(flycheck-ert-should-syntax-check
"language/erlang/rebar3/_checkouts/dependency/src/dependency.erl" 'erlang-mode)
;; Ensure that the dependency file wasn't built as standalone
;; project which would create a separate _build directory
(should (not (file-exists-p
(flycheck-ert-resource-filename
"language/erlang/rebar3/_build/default/lib/dependency/_build")))))
(flycheck-ert-def-checker-test eruby-erubis eruby nil
(flycheck-ert-should-syntax-check
"language/eruby.erb" '(html-erb-mode rhtml-mode)
'(5 nil error "syntax error, unexpected keyword_end" :checker eruby-erubis)))
(flycheck-ert-def-checker-test fortran-gfortran fortran error
(flycheck-ert-should-syntax-check
"language/fortran/error.f" '(fortran-mode f90-mode)
'(1 1 error "Non-numeric character in statement label at (1)"
:checker fortran-gfortran)
'(1 1 error "Unclassifiable statement at (1)" :checker fortran-gfortran)
'(2 1 error "Non-numeric character in statement label at (1)"
:checker fortran-gfortran)
'(2 1 error "Unclassifiable statement at (1)" :checker fortran-gfortran)
'(3 1 error "Non-numeric character in statement label at (1)"
:checker fortran-gfortran)
'(3 1 error "Unclassifiable statement at (1)" :checker fortran-gfortran)))
(flycheck-ert-def-checker-test fortran-gfortran fortran free-form-error
(let ((flycheck-gfortran-layout 'free))
(flycheck-ert-should-syntax-check
"language/fortran/error.f" '(fortran-mode f90-mode)
'(3 3 error "Expecting END PROGRAM statement at (1)"
:checker fortran-gfortran))))
(flycheck-ert-def-checker-test fortran-gfortran fortran warning
(flycheck-ert-should-syntax-check
"language/fortran/warning.f90" '(fortran-mode f90-mode)
'(1 20 warning "Unused dummy argument 'p' at (1)"
:checker fortran-gfortran)
'(18 9 warning "Same actual argument associated with INTENT(IN) argument 'a' and INTENT(OUT) argument 'b' at (1)"
:checker fortran-gfortran)))
(flycheck-ert-def-checker-test go-gofmt go syntax-error
(flycheck-ert-should-syntax-check
"language/go/src/syntax/syntax-error.go" 'go-mode
'(5 9 error "expected '(', found 'IDENT' ta" :checker go-gofmt)
'(6 1 error "expected ')', found '}'" :checker go-gofmt)))
(flycheck-ert-def-checker-test (go-build go-golint go-vet) go complete-chain
(skip-unless (funcall (flycheck-checker-get 'go-vet 'predicate)))
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
(flycheck-ert-should-syntax-check
"language/go/src/warnings.go" 'go-mode
'(4 nil error "imported and not used: \"fmt\"" :checker go-build)
'(4 2 warning "should not use dot imports" :checker go-golint)
'(7 1 warning "exported function Warn should have comment or be unexported"
:checker go-golint)
'(8 nil error "undefined: fmt in fmt.Printf" :checker go-build)
'(11 1 warning "exported function Warnf should have comment or be unexported"
:checker go-golint)
'(12 nil error "undefined: fmt in fmt.Printf" :checker go-build)
'(17 nil error "undefined: fmt in fmt.Printf" :checker go-build)
'(17 nil warning "arg 1 for printf verb %s of wrong type: untyped int"
:checker go-vet)
'(19 nil error "cannot use 1 (type int) as type string in argument to Warnf"
:checker go-build)
'(23 nil warning "unreachable code" :checker go-vet)
'(25 9 warning "if block ends with a return statement, so drop this else and outdent its block"
:checker go-golint))))
(flycheck-ert-def-checker-test go-build go handles-packages
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
(flycheck-ert-should-syntax-check "language/go/src/b1/main.go" 'go-mode)))
(flycheck-ert-def-checker-test go-build go missing-package
(let* ((go-root (or (getenv "GOROOT") "/usr/local/go"))
(go-root-pkg (concat go-root "/src")))
(flycheck-ert-with-env '(("GOPATH" . nil))
(flycheck-ert-should-syntax-check
"language/go/src/b1/main.go" 'go-mode
`(4 2 error ,(format "cannot find package \"b2\" in any of:\n\t%s/b2 (from $GOROOT)\n\t($GOPATH not set)"
go-root-pkg)
:checker go-build)))))
(flycheck-ert-def-checker-test go-build go directory-with-two-packages
(let ((flycheck-disabled-checkers '(go-errcheck go-unconvert go-megacheck)))
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "checkers/go")))
(flycheck-ert-should-syntax-check
"checkers/go/src/multipkg/a.go" 'go-mode
`(1 nil info
,(concat "can't load package: package multipkg: "
"found packages a (a.go) and b (b.go) in "
(flycheck-ert-resource-filename
"checkers/go/src/multipkg"))
:checker go-build)))))
(flycheck-ert-def-checker-test go-test go nil
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "checkers/go")))
(flycheck-ert-should-syntax-check
"language/go/src/test/test-error_test.go" 'go-mode
'(8 nil error "undefined: fmt in fmt.Println" :checker go-test))))
(flycheck-ert-def-checker-test go-errcheck go nil
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
(flycheck-ert-should-syntax-check
"language/go/src/errcheck/errcheck.go" 'go-mode
'(7 9 warning "Ignored `error` returned from `f.Close()`"
:checker go-errcheck)
'(9 9 warning "Ignored `error` returned from `os.Stat(\"enoent\")`"
:checker go-errcheck))))
(flycheck-ert-def-checker-test go-unconvert go nil
:tags '(language-go external-tool)
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
(flycheck-ert-should-syntax-check
"language/go/src/unconvert/unconvert.go" 'go-mode
'(7 17 warning "unnecessary conversion"
:checker go-unconvert))))
(flycheck-ert-def-checker-test go-megacheck go nil
:tags '(language-go external-tool)
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
(flycheck-ert-should-syntax-check
"language/go/src/megacheck/megacheck1.go" 'go-mode
'(8 6 warning "should omit values from range; this loop is equivalent to `for range ...` (S1005)"
:checker go-megacheck)
'(12 21 warning "calling strings.Replace with n == 0 will return no results, did you mean -1? (SA1018)"
:checker go-megacheck)
'(16 6 warning "func unused is unused (U1000)"
:checker go-megacheck))))
(flycheck-ert-def-checker-test go-megacheck-disabled-checkers go nil
:tags '(language-go external-tool)
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
;; Run with simple and unused checkers disabled
(let ((flycheck-go-megacheck-disabled-checkers '("simple" "unused")))
(flycheck-ert-should-syntax-check
"language/go/src/megacheck/megacheck1.go" 'go-mode
'(12 21 warning "calling strings.Replace with n == 0 will return no results, did you mean -1? (SA1018)"
:checker go-megacheck)))))
(flycheck-ert-def-checker-test groovy groovy syntax-error
;; Work around
;; https://github.com/Groovy-Emacs-Modes/groovy-emacs-modes/issues/11
(require 'cl)
(flycheck-ert-should-syntax-check
"language/groovy.groovy" 'groovy-mode
'(2 14 error "unexpected token: {" :checker groovy)))
(flycheck-ert-def-checker-test haml haml nil
(flycheck-ert-should-syntax-check
"language/haml.haml" 'haml-mode
'(5 nil error "Inconsistent indentation: 3 spaces used for indentation, but the rest of the document was indented using 2 spaces."
:checker haml)))
(flycheck-ert-def-checker-test handlebars handlebars nil
(flycheck-ert-should-syntax-check
"language/handlebars.hbs" '(handlebars-mode web-mode)
'(2 nil error "Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'"
:checker handlebars)))
(flycheck-ert-def-checker-test haskell-stack-ghc haskell syntax-error
(skip-unless (file-exists-p (getenv "HOME")))
(let ((flycheck-disabled-checkers '(haskell-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/SyntaxError.hs" 'haskell-mode
'(3 1 error "parse error on input `module'" :checker haskell-stack-ghc))))
(flycheck-ert-def-checker-test haskell-stack-ghc haskell type-error
(skip-unless (file-exists-p (getenv "HOME")))
(let ((flycheck-disabled-checkers '(haskell-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/Error.hs" 'haskell-mode
'(4 16 error "* Couldn't match type `Bool' with `[Char]'
Expected type: String
Actual type: Bool
* In the first argument of `putStrLn', namely `True'
In the expression: putStrLn True
In an equation for `foo': foo = putStrLn True" :checker haskell-stack-ghc))))
(flycheck-ert-def-checker-test (haskell-stack-ghc haskell-hlint) haskell literate
(skip-unless (file-exists-p (getenv "HOME")))
(let ((flycheck-disabled-checkers '(haskell-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/Literate.lhs" 'literate-haskell-mode
'(6 1 warning "Top-level binding with no type signature: foo :: a"
:id "-Wmissing-signatures"
:checker haskell-stack-ghc))))
(flycheck-ert-def-checker-test (haskell-stack-ghc haskell-hlint) haskell
complete-chain
(skip-unless (file-exists-p (getenv "HOME")))
(let ((flycheck-disabled-checkers '(haskell-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/Warnings.hs" 'haskell-mode
'(4 1 warning "Eta reduce
Found:
spam eggs = map lines eggs
Why not:
spam = map lines" :checker haskell-hlint)
'(4 1 warning "Top-level binding with no type signature:
spam :: [String] -> [[String]]"
:id "-Wmissing-signatures"
:checker haskell-stack-ghc)
'(7 8 info "Redundant bracket
Found:
(putStrLn \"hello world\")
Why not:
putStrLn \"hello world\"" :checker haskell-hlint))))
(flycheck-ert-def-checker-test haskell-ghc haskell syntax-error
(let ((flycheck-disabled-checkers '(haskell-stack-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/SyntaxError.hs" 'haskell-mode
'(3 1 error "parse error on input `module'" :checker haskell-ghc))))
(flycheck-ert-def-checker-test haskell-ghc haskell type-error
(let ((flycheck-disabled-checkers '(haskell-stack-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/Error.hs" 'haskell-mode
'(4 16 error "* Couldn't match type `Bool' with `[Char]'
Expected type: String
Actual type: Bool
* In the first argument of `putStrLn', namely `True'
In the expression: putStrLn True
In an equation for `foo': foo = putStrLn True" :checker haskell-ghc))))
(flycheck-ert-def-checker-test (haskell-ghc haskell-hlint) haskell literate
(let ((flycheck-disabled-checkers '(haskell-stack-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/Literate.lhs" 'literate-haskell-mode
'(6 1 warning "Top-level binding with no type signature: foo :: forall a. a"
:id "-Wmissing-signatures"
:checker haskell-ghc))))
(flycheck-ert-def-checker-test (haskell-ghc haskell-hlint) haskell
complete-chain
(let ((flycheck-disabled-checkers '(haskell-stack-ghc)))
(flycheck-ert-should-syntax-check
"language/haskell/Warnings.hs" 'haskell-mode
'(4 1 warning "Eta reduce
Found:
spam eggs = map lines eggs
Why not:
spam = map lines" :checker haskell-hlint)
'(4 1 warning "Top-level binding with no type signature:
spam :: [String] -> [[String]]"
:id "-Wmissing-signatures"
:checker haskell-ghc)
'(7 8 info "Redundant bracket
Found:
(putStrLn \"hello world\")
Why not:
putStrLn \"hello world\"" :checker haskell-hlint))))
(flycheck-ert-def-checker-test html-tidy html nil
(flycheck-ert-should-syntax-check
"language/html.html" '(html-mode)
'(3 1 warning "missing <!DOCTYPE> declaration"
:checker html-tidy)
'(8 5 error "<spam> is not recognized!"
:checker html-tidy)
'(8 5 warning "discarding unexpected <spam>"
:checker html-tidy)))
(defconst flycheck-test-javascript-modes '(js-mode
js2-mode
js3-mode
js2-jsx-mode
rjsx-mode))
(when (version<= "25" emacs-version)
(add-to-list 'flycheck-test-javascript-modes 'js-jsx-mode))
(flycheck-ert-def-checker-test javascript-jshint javascript syntax-error
:tags '(checkstyle-xml)
;; Silence JS2 and JS3 parsers
(let ((js2-mode-show-parse-errors nil)
(js2-mode-show-strict-warnings nil)
(js3-mode-show-parse-errors nil)
(flycheck-disabled-checkers
'(javascript-jscs javascript-eslint javascript-gjslint)))
(flycheck-ert-should-syntax-check
"language/javascript/syntax-error.js" '(js-mode js2-mode js3-mode rjsx-mode)
'(3 4 error "Unmatched '('." :checker javascript-jshint :id "E019")
'(3 25 error "Expected an identifier and instead saw ')'."
:checker javascript-jshint :id "E030")
'(4 1 error "Unrecoverable syntax error. (100% scanned)."
:checker javascript-jshint :id "E041"))))
(flycheck-ert-def-checker-test javascript-jshint javascript nil
:tags '(checkstyle-xml)
(let ((flycheck-jshintrc "jshintrc")
(flycheck-disabled-checkers
'(javascript-jscs javascript-eslint javascript-gjslint)))
(flycheck-ert-should-syntax-check
"language/javascript/warnings.js" '(js-mode js2-mode js3-mode rjsx-mode)
'(4 9 warning "'foo' is defined but never used." :id "W098"
:checker javascript-jshint))))
(flycheck-ert-def-checker-test javascript-eslint javascript error
:tags '(checkstyle-xml)
(let ((flycheck-disabled-checkers '(javascript-jshint)))
(flycheck-ert-should-syntax-check
"language/javascript/syntax-error.js" flycheck-test-javascript-modes
'(3 25 error "Parsing error: Unexpected token )" :checker javascript-eslint))))
(flycheck-ert-def-checker-test javascript-eslint javascript warning
:tags '(checkstyle-xml)
(let ((flycheck-disabled-checkers '(javascript-jshint javascript-jscs)))
(flycheck-ert-should-syntax-check
"language/javascript/warnings.js" flycheck-test-javascript-modes
'(3 2 warning "Use the function form of 'use strict'." :id "strict"
:checker javascript-eslint)
'(4 9 warning "'foo' is assigned a value but never used."
:id "no-unused-vars" :checker javascript-eslint))))
(flycheck-ert-def-checker-test javascript-jscs javascript nil
:tags '(checkstyle-xml)
(let ((flycheck-jscsrc "jscsrc")
(flycheck-disabled-checkers
'(javascript-jshint javascript-eslint)))
(flycheck-ert-should-syntax-check
"language/javascript/style.js" flycheck-test-javascript-modes
'(4 1 error "validateIndentation: Invalid indentation character:"
:checker javascript-jscs)
'(4 1 error "validateIndentation: Expected indentation of 0 characters"
:checker javascript-jscs))))
(flycheck-ert-def-checker-test javascript-jscs javascript no-config
:tags '(checkstyle-xml)
(let ((flycheck-disabled-checkers
'(javascript-jshint javascript-eslint)))
(flycheck-ert-should-syntax-check
"language/javascript/style.js" flycheck-test-javascript-modes
'(1 nil warning "No JSCS configuration found. Set `flycheck-jscsrc' for JSCS"
:checker javascript-jscs))))
(flycheck-ert-def-checker-test (javascript-jshint javascript-jscs)
javascript complete-chain
:tags '(checkstyle-xml)
(let ((flycheck-jshintrc "jshintrc")
(flycheck-jscsrc "jscsrc")
(flycheck-disabled-checkers '(javascript-eslint javascript-gjslint)))
(flycheck-ert-should-syntax-check
"language/javascript/warnings.js" '(js-mode js2-mode js3-mode rjsx-mode)
'(4 1 error "validateIndentation: Expected indentation of 0 characters"
:checker javascript-jscs)
'(4 9 warning "'foo' is defined but never used." :id "W098"
:checker javascript-jshint))))
(flycheck-ert-def-checker-test (javascript-eslint javascript-jscs)
javascript complete-chain
:tags '(checkstyle-xml)
(let ((flycheck-jscsrc "jscsrc")
(flycheck-disabled-checkers '(javascript-jshint)))
(flycheck-ert-should-syntax-check
"language/javascript/warnings.js" flycheck-test-javascript-modes
'(3 2 warning "Use the function form of 'use strict'." :id "strict"
:checker javascript-eslint)
'(4 1 error "validateIndentation: Expected indentation of 0 characters"
:checker javascript-jscs)
'(4 9 warning "'foo' is assigned a value but never used." :id "no-unused-vars"
:checker javascript-eslint))))
(flycheck-ert-def-checker-test javascript-standard javascript error
(let ((flycheck-checker 'javascript-standard))
(flycheck-ert-should-syntax-check
"language/javascript/style.js" flycheck-test-javascript-modes
'(3 10 error "Missing space before function parentheses."
:checker javascript-standard)
'(4 2 error "Unexpected tab character."
:checker javascript-standard)
'(4 2 error "Expected indentation of 2 spaces but found 1 tab."
:checker javascript-standard)
'(4 6 error "'foo' is assigned a value but never used."
:checker javascript-standard)
'(4 13 error "Strings must use singlequote."
:checker javascript-standard)
'(4 27 error "Extra semicolon."
:checker javascript-standard)
'(5 5 error "Extra semicolon."
:checker javascript-standard))))
(flycheck-ert-def-checker-test javascript-standard javascript semistandard
(let ((flycheck-checker 'javascript-standard)
(flycheck-javascript-standard-executable "semistandard"))
(flycheck-ert-should-syntax-check
"language/javascript/style.js" flycheck-test-javascript-modes
'(3 10 error "Missing space before function parentheses."
:checker javascript-standard)
'(4 2 error "Unexpected tab character."
:checker javascript-standard)
'(4 2 error "Expected indentation of 2 spaces but found 1 tab."
:checker javascript-standard)
'(4 6 error "'foo' is assigned a value but never used."
:checker javascript-standard)
'(4 13 error "Strings must use singlequote."
:checker javascript-standard))))
(flycheck-ert-def-checker-test json-jsonlint json nil
(flycheck-ert-should-syntax-check
"language/json.json" 'json-mode
'(1 44 error "found: ',' - expected: 'EOF'." :checker json-jsonlint)))
(flycheck-ert-def-checker-test json-python-json json nil
(let ((flycheck-disabled-checkers '(json-jsonlint)))
(flycheck-ert-should-syntax-check
"language/json.json" 'json-mode
'(1 44 error "Extra data" :checker json-python-json))))
(flycheck-ert-def-checker-test less less file-error
(let* ((candidates (list "no-such-file.less"
"no-such-file.less"))
(message (string-join candidates ",")))
(flycheck-ert-should-syntax-check
"language/less/file-error.less" 'less-css-mode
`(3 1 error ,(concat "'no-such-file.less' wasn't found. Tried - "
message)
:checker less))))
(flycheck-ert-def-checker-test less less syntax-error
(flycheck-ert-should-syntax-check
"language/less/syntax-error.less" 'less-css-mode
'(1 1 error "Unrecognised input" :checker less)))
(flycheck-ert-def-checker-test llvm-llc llvm nil
(flycheck-ert-should-syntax-check
"language/llvm.ll" 'llvm-mode
'(4 19 error "'%tmp' defined with type 'i32'" :checker llvm-llc)))
(flycheck-ert-def-checker-test lua-luacheck lua syntax-error
(flycheck-ert-should-syntax-check
"language/lua/syntax-error.lua" 'lua-mode
'(5 7 error "unfinished string" :id "E011" :checker lua-luacheck)))
(flycheck-ert-def-checker-test lua-luacheck lua warnings
(flycheck-ert-should-syntax-check
"language/lua/warnings.lua" 'lua-mode
'(1 1 warning "setting non-standard global variable 'global_var'"
:id "W111" :checker lua-luacheck)
'(3 16 warning "unused function 'test'"
:id "W211" :checker lua-luacheck)
'(3 21 warning "unused argument 'arg'"
:id "W212" :checker lua-luacheck)
'(4 11 warning "variable 'var2' is never set"
:id "W221" :checker lua-luacheck)))
(flycheck-ert-def-checker-test lua-luacheck lua custom-luacheckrc
(let ((flycheck-luacheckrc "custom.luacheckrc"))
(flycheck-ert-should-syntax-check
"language/lua/warnings.lua" 'lua-mode
'(1 1 warning "setting non-standard global variable 'global_var'"
:id "W111" :checker lua-luacheck)
'(3 16 warning "unused function 'test'"
:id "W211" :checker lua-luacheck)
'(4 11 warning "variable 'var2' is never set"
:id "W221" :checker lua-luacheck))))
(flycheck-ert-def-checker-test lua-luacheck lua custom-standards
(let ((flycheck-luacheck-standards '("ngx_lua")))
(flycheck-ert-should-syntax-check
"language/lua/ngx_lua.warnings.lua" 'lua-mode
'(3 16 warning "unused function 'test'"
:id "W211" :checker lua-luacheck)
'(3 21 warning "unused argument 'arg'"
:id "W212" :checker lua-luacheck)
'(4 11 warning "variable 'var2' is never set"
:id "W221" :checker lua-luacheck))))
(flycheck-ert-def-checker-test lua lua nil
(let ((flycheck-disabled-checkers '(lua-luacheck)))
(flycheck-ert-should-syntax-check
"language/lua/syntax-error.lua" 'lua-mode
'(5 nil error "unfinished string near '\"oh no'"
:checker lua))))
(flycheck-ert-def-checker-test (perl perl-perlcritic) perl nil
(flycheck-ert-should-syntax-check
"language/perl.pl" '(perl-mode cperl-mode)
'(6 nil error "Global symbol \"$x\" requires explicit package name (did you forget to declare \"my $x\"?)"
:checker perl)
'(6 nil error "BEGIN not safe after errors--compilation aborted"
:checker perl)
'(6 6 error "Glob written as <...> (See page 167 of PBP)"
:id "BuiltinFunctions::RequireGlobFunction" :checker perl-perlcritic)))
(flycheck-ert-def-checker-test php php syntax-error
(flycheck-ert-should-syntax-check
"language/php/syntax-error.php" 'php-mode
'(8 nil error "Assignments can only happen to writable values" :checker php)))
(flycheck-ert-def-checker-test (php php-phpcs php-phpmd) php nil
:tags '(phpmd-xml checkstyle-xml)
(flycheck-ert-should-syntax-check
"language/php/warnings.php" 'php-mode
'(1 1 error "Missing file doc comment"
:id "PEAR.Commenting.FileComment.Missing" :checker php-phpcs)
'(21 nil warning "Avoid unused private fields such as '$FOO'."
:id "UnusedPrivateField" :checker php-phpmd)
'(21 20 error "Private member variable \"FOO\" must be prefixed with an underscore"
:id "PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore"
:checker php-phpcs)
'(23 5 error "The open comment tag must be the only content on the line"
:id "Generic.Commenting.DocComment.ContentAfterOpen"
:checker php-phpcs)
'(23 5 error "Doc comment for parameter \"$baz\" missing"
:id "PEAR.Commenting.FunctionComment.MissingParamTag"
:checker php-phpcs)
'(23 9 error "Doc comment short description must be on the first line"
:id "Generic.Commenting.DocComment.SpacingBeforeShort"
:checker php-phpcs)
'(23 29 error "The close comment tag must be the only content on the line"
:id "Generic.Commenting.DocComment.ContentBeforeClose"
:checker php-phpcs)
'(23 29 error "Missing @return tag in function comment"
:id "PEAR.Commenting.FunctionComment.MissingReturn"
:checker php-phpcs)
'(24 nil warning "Avoid unused private methods such as 'bar'."
:id "UnusedPrivateMethod" :checker php-phpmd)
'(24 nil warning "Avoid unused parameters such as '$baz'."
:id "UnusedFormalParameter" :checker php-phpmd)
'(24 13 error "Private method name \"A::bar\" must be prefixed with an underscore"
:id "PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"
:checker php-phpcs)
'(26 nil warning "Avoid variables with short names like $i. Configured minimum length is 3."
:id "ShortVariable" :checker php-phpmd)
'(26 nil warning "Avoid unused local variables such as '$i'."
:id "UnusedLocalVariable" :checker php-phpmd)
'(26 12 error "TRUE, FALSE and NULL must be lowercase; expected \"false\" but found \"FALSE\""
:id "Generic.PHP.LowerCaseConstant.Found" :checker php-phpcs)))
(flycheck-ert-def-checker-test proselint (text markdown) nil
;; Unset LC_ALL which is set to LC_ALL=C for other checkers in ./run.el,
;; because Click, used by ProseLint, when running with python 3 will refuse to
;; work unless an Unicode locale is exported. See:
;; http://click.pocoo.org/5/python3/#python-3-surrogate-handling
(flycheck-ert-with-env '(("LC_ALL" . nil))
(flycheck-ert-should-syntax-check
"language/text.txt" 'text-mode
'(1 7 warning "Substitute 'damn' every time you're inclined to write 'very;' your editor will delete it and the writing will be just as it should be."
:id "weasel_words.very"
:checker proselint)
'(2 4 warning "Redundancy. Use 'associate' instead of 'associate together'."
:id "redundancy.garner"
:checker proselint)
'(3 5 warning "Gender bias. Use 'lawyer' instead of 'lady lawyer'."
:id "sexism.misc"
:checker proselint))))
(flycheck-ert-def-checker-test processing processing syntax-error
(flycheck-ert-should-syntax-check
"language/processing/syntax_error/syntax_error.pde" 'processing-mode
'(4 2 error "Syntax error, maybe a missing semicolon?"
:checker processing)))
(flycheck-ert-def-checker-test protobuf-protoc protobuf syntax-error
(flycheck-ert-should-syntax-check
"language/protobuf.proto" 'protobuf-mode
'(2 23 error "Missing field number."
:checker protobuf-protoc)))
(flycheck-ert-def-checker-test pug pug syntax-error
(flycheck-ert-should-syntax-check
"language/pug/pug.pug" 'pug-mode
'(2 1 error "unexpected token \"indent\"" :checker pug)))
(flycheck-ert-def-checker-test pug pug include-extends-error
(flycheck-ert-should-syntax-check
"language/pug/pug-extends.pug" 'pug-mode
'(1 nil error "the \"basedir\" option is required to use includes and extends with \"absolute\" paths"
:checker pug)))
(flycheck-ert-def-checker-test pug pug type-error
(flycheck-ert-should-syntax-check
"language/pug/pug-runtime-error.pug" 'pug-mode
'(5 nil error "Cannot read property 'bar' of undefined" :checker pug)))
;; N.B. the puppet 4 and 3 tests are mutually exclusive
;; due to one having column and the other not
(flycheck-ert-def-checker-test puppet-parser puppet parser-error-puppet-4
(skip-unless (version<= "4" (shell-command-to-string
"printf %s \"$(puppet --version)\"")))
(flycheck-ert-should-syntax-check
"language/puppet/parser-error.pp" 'puppet-mode
'(3 9 error "Syntax error at '>'" :checker puppet-parser)))
(flycheck-ert-def-checker-test puppet-parser puppet parser-error-puppet-3
(skip-unless (version<= (shell-command-to-string
"printf %s \"$(puppet --version)\"") "4"))
(flycheck-ert-should-syntax-check
"language/puppet/puppet3-parser-error.pp" 'puppet-mode
'(4 nil error "Syntax error at 'helloagain'; expected '}'"
:checker puppet-parser))
(flycheck-ert-should-syntax-check
"language/puppet/puppet3-parser-multiline-error.pp" 'puppet-mode
'(4 nil error "Unclosed quote after '' in '\n}\n'"
:checker puppet-parser)))
(flycheck-ert-def-checker-test puppet-lint puppet nil
(flycheck-ert-should-syntax-check
"language/puppet/warnings.pp" 'puppet-mode
'(2 nil error "foo::bar not in autoload module layout (autoloader_layout)"
:checker puppet-lint)
'(3 nil warning "case statement without a default case (case_without_default)"
:checker puppet-lint)))
(flycheck-ert-def-checker-test python-flake8 python syntax-error
(let ((python-indent-guess-indent-offset nil)) ; Silence Python Mode!
(flycheck-ert-should-syntax-check
"language/python/syntax-error.py" 'python-mode
'(3 12 error "SyntaxError: invalid syntax" :id "E999"
:checker python-flake8))))
(flycheck-ert-def-checker-test python-flake8 python nil
(flycheck-ert-should-syntax-check
"language/python/test.py" 'python-mode
'(5 1 warning "'.antigravit' imported but unused" :id "F401"
:checker python-flake8)
'(7 1 warning "expected 2 blank lines, found 1" :id "E302"
:checker python-flake8)
'(12 29 warning "unexpected spaces around keyword / parameter equals"
:id "E251" :checker python-flake8)
'(12 31 warning "unexpected spaces around keyword / parameter equals"
:id "E251" :checker python-flake8)
'(21 1 warning "expected 2 blank lines after class or function definition, found 1"
:id "E305" :checker python-flake8)
'(22 1 error "undefined name 'antigravity'" :id "F821"
:checker python-flake8)))
(flycheck-ert-def-checker-test python-pylint python syntax-error
(let ((flycheck-disabled-checkers '(python-flake8))
(python-indent-guess-indent-offset nil)) ; Silence Python Mode
(flycheck-ert-should-syntax-check
"language/python/syntax-error.py" 'python-mode
'(3 1 error "invalid syntax (<string>, line 3)"
:id "syntax-error" :checker python-pylint))))
(flycheck-ert-def-checker-test python-pylint python nil
(let ((flycheck-disabled-checkers '(python-flake8)))
(flycheck-ert-should-syntax-check
"language/python/test.py" 'python-mode
'(1 1 info "Missing module docstring" :id "missing-docstring" :checker python-pylint)
'(4 1 error "Unable to import 'spam'" :id "import-error" :checker python-pylint)
'(5 1 error "No name 'antigravit' in module 'python'" :id "no-name-in-module"
:checker python-pylint)
'(5 1 warning "Unused import antigravit" :id "unused-import"
:checker python-pylint)
'(7 1 info "Missing class docstring" :id "missing-docstring" :checker python-pylint)
'(9 5 info "Invalid method name \"withEggs\"" :id "invalid-name"
:checker python-pylint)
'(9 5 info "Missing method docstring" :id "missing-docstring" :checker python-pylint)
'(9 5 warning "Method could be a function" :id "no-self-use"
:checker python-pylint)
'(12 1 info "No space allowed around keyword argument assignment"
:id "bad-whitespace" :checker python-pylint)
'(12 5 info "Missing method docstring" :id "missing-docstring" :checker python-pylint)
'(12 5 warning "Method could be a function" :id "no-self-use"
:checker python-pylint)
'(14 16 error "Module 'sys' has no 'python_version' member" :id "no-member"
:checker python-pylint)
'(22 1 error "Undefined variable 'antigravity'" :id "undefined-variable"
:checker python-pylint))))
(flycheck-ert-def-checker-test python-pylint python no-symbolic-id
(let ((flycheck-disabled-checkers '(python-flake8))
(flycheck-pylint-use-symbolic-id nil))
(flycheck-ert-should-syntax-check
"language/python/test.py" 'python-mode
'(1 1 info "Missing module docstring" :id "C0111" :checker python-pylint)
'(4 1 error "Unable to import 'spam'" :id "E0401" :checker python-pylint)
'(5 1 error "No name 'antigravit' in module 'python'" :id "E0611"
:checker python-pylint)
'(5 1 warning "Unused import antigravit" :id "W0611"
:checker python-pylint)
'(7 1 info "Missing class docstring" :id "C0111" :checker python-pylint)
'(9 5 info "Invalid method name \"withEggs\"" :id "C0103"
:checker python-pylint)
'(9 5 info "Missing method docstring" :id "C0111" :checker python-pylint)
'(9 5 warning "Method could be a function" :id "R0201"
:checker python-pylint)
'(12 1 info "No space allowed around keyword argument assignment"
:id "C0326" :checker python-pylint)
'(12 5 info "Missing method docstring" :id "C0111" :checker python-pylint)
'(12 5 warning "Method could be a function" :id "R0201"
:checker python-pylint)
'(14 16 error "Module 'sys' has no 'python_version' member" :id "E1101"
:checker python-pylint)
'(22 1 error "Undefined variable 'antigravity'" :id "E0602"
:checker python-pylint))))
(flycheck-ert-def-checker-test python-pycompile python python27
(skip-unless (executable-find "python2"))
(let ((flycheck-disabled-checkers '(python-flake8 python-pylint))
(flycheck-python-pycompile-executable "python2")
(python-indent-guess-indent-offset nil))
(flycheck-ert-should-syntax-check
"language/python/syntax-error.py" 'python-mode
`(3 nil error "invalid syntax" :checker python-pycompile))))
(flycheck-ert-def-checker-test python-pycompile python has-no-warnings
(let ((flycheck-disabled-checkers '(python-flake8 python-pylint)))
(flycheck-ert-should-syntax-check
"language/python/test.py" 'python-mode)))
(flycheck-ert-def-checker-test r-lintr r nil
;; Disable caching in lintr tests to make sure that the file is re-checked
;; every time
(skip-unless (flycheck-r-has-lintr (flycheck-checker-executable 'r-lintr)))
(let ((flycheck-lintr-caching nil))
(flycheck-ert-should-syntax-check
"language/r.R" 'R-mode
'(1 28 info "Opening curly braces should never go on their own line and should always be followed by a new line."
:checker r-lintr)
'(1 56 info "Put spaces around all infix operators." :checker r-lintr)
'(4 6 warning "Do not use absolute paths." :checker r-lintr)
'(7 5 error "unexpected end of input" :checker r-lintr))))
(flycheck-ert-def-checker-test racket racket nil
(skip-unless (funcall (flycheck-checker-get 'racket 'predicate)))
(flycheck-ert-should-syntax-check
"language/racket.rkt" 'racket-mode
'(4 3 error "read: expected a `)' to close `('" :checker racket)))
(flycheck-ert-def-checker-test rpm-rpmlint rpm nil
(flycheck-ert-should-syntax-check
"language/rpm.spec" '(sh-mode rpm-spec-mode)
'(1 nil warning "no-cleaning-of-buildroot %install" :checker rpm-rpmlint)
'(1 nil warning "no-cleaning-of-buildroot %clean" :checker rpm-rpmlint)
'(1 nil warning "no-buildroot-tag" :checker rpm-rpmlint)
'(7 nil error "buildarch-instead-of-exclusivearch-tag x86_64"
:checker rpm-rpmlint)
'(22 nil warning "macro-in-%changelog %{_bindir}" :checker rpm-rpmlint)))
(flycheck-ert-def-checker-test markdown-mdl markdown nil
(flycheck-ert-should-syntax-check
"language/markdown.md" 'markdown-mode
'(1 nil error "First header should be a top level header"
:id "MD002" :checker markdown-mdl)))
(flycheck-ert-def-checker-test nix nix nil
(flycheck-ert-should-syntax-check
"language/nix.nix" 'nix-mode
'(3 1 error "syntax error, unexpected IN, expecting ';'," :checker nix)))
(ert-deftest flycheck-locate-sphinx-source-directory/not-in-a-sphinx-project ()
:tags '(language-rst)
(flycheck-ert-with-resource-buffer "language/rst/errors.rst"
(should-not (flycheck-locate-sphinx-source-directory))))
(ert-deftest flycheck-locate-sphinx-source-directory/in-a-sphinx-project ()
:tags '(language-rst)
(flycheck-ert-with-resource-buffer "language/rst/sphinx/index.rst"
(should (string= (flycheck-locate-sphinx-source-directory)
(flycheck-ert-resource-filename "language/rst/sphinx/")))))
(flycheck-ert-def-checker-test rst rst nil
(flycheck-ert-should-syntax-check
"language/rst/errors.rst" 'rst-mode
'(8 nil warning "Title underline too short." :checker rst)
'(14 nil error "Unexpected section title." :checker rst)
'(16 nil error "Unknown target name: \"restructuredtext\"." :checker rst)
'(19 nil warning "Title underline too short." :checker rst)
'(21 nil error "Unknown target name: \"cool\"." :checker rst)
'(26 nil error "Unexpected section title." :checker rst)))
(flycheck-ert-def-checker-test rst-sphinx rst nil
(flycheck-ert-should-syntax-check
"language/rst/sphinx/index.rst" 'rst-mode
'(2 nil warning "Title underline too short." :checker rst-sphinx)
'(9 nil error "Unknown target name: \"cool\"." :checker rst-sphinx)
'(9 nil warning "'envvar' reference target not found: FOO"
:checker rst-sphinx)))
(flycheck-ert-def-checker-test rst-sphinx rst not-outside-of-a-sphinx-project
(flycheck-ert-with-resource-buffer "language/rst/errors.rst"
(rst-mode)
(should-not (flycheck-may-use-checker 'rst-sphinx))))
(flycheck-ert-def-checker-test ruby-rubocop ruby syntax-error
(flycheck-ert-should-syntax-check
"language/ruby/syntax-error.rb" 'ruby-mode
'(5 7 error "unexpected token tCONSTANT (Using Ruby 2.1 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)"
:checker ruby-rubocop)
'(5 24 error "unterminated string meets end of file (Using Ruby 2.1 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)"
:checker ruby-rubocop)))
(flycheck-ert-def-checker-test ruby-rubylint ruby syntax-error
(ert-skip "Pending: https://github.com/YorickPeterse/ruby-lint/issues/202")
(let ((flycheck-disabled-checkers '(ruby-rubocop ruby-reek)))
(flycheck-ert-should-syntax-check
"language/ruby/syntax-error.rb" 'ruby-mode
'(5 7 error "unexpected token tCONSTANT" :checker ruby-rubylint))))
(flycheck-ert-def-checker-test ruby ruby syntax-error
(let ((flycheck-disabled-checkers '(ruby-rubocop ruby-reek ruby-rubylint)))
(flycheck-ert-should-syntax-check
"language/ruby/syntax-error.rb" 'ruby-mode
'(4 nil warning "assigned but unused variable - days" :checker ruby)
'(5 nil error "syntax error, unexpected tCONSTANT, expecting end-of-input"
:checker ruby))))
(flycheck-ert-def-checker-test ruby-jruby ruby syntax-error
(let ((flycheck-disabled-checkers '(ruby-rubocop ruby-reek ruby-rubylint ruby)))
(flycheck-ert-should-syntax-check
"language/ruby/syntax-error.rb" 'ruby-mode
'(5 nil error "syntax error, unexpected tCONSTANT" :checker ruby-jruby))))
(flycheck-ert-def-checker-test (ruby-rubocop ruby-reek ruby-rubylint) ruby with-rubylint
(flycheck-ert-should-syntax-check
"language/ruby/warnings.rb" 'ruby-mode
'(3 nil warning "Person assumes too much for instance variable '@name'"
:id "InstanceVariableAssumption" :checker ruby-reek)
'(3 1 info "Missing top-level class documentation comment."
:id "Style/Documentation" :checker ruby-rubocop)
'(5 5 warning "unused local variable arr" :checker ruby-rubylint)
'(5 5 warning "Useless assignment to variable - `arr`."
:id "Lint/UselessAssignment" :checker ruby-rubocop)
'(5 11 info "Use `%i` or `%I` for an array of symbols."
:id "Style/SymbolArray" :checker ruby-rubocop)
'(6 10 info "Prefer single-quoted strings when you don't need string interpolation or special symbols."
:id "Style/StringLiterals" :checker ruby-rubocop)
'(10 5 info "the use of then/do is not needed here" :checker ruby-rubylint)
'(10 5 info "Use a guard clause instead of wrapping the code inside a conditional expression."
:id "Style/GuardClause":checker ruby-rubocop)
'(10 5 info "Favor modifier `if` usage when having a single-line body. Another good alternative is the usage of control flow `&&`/`||`."
:id "Style/IfUnlessModifier" :checker ruby-rubocop)
'(10 8 warning "Literal `true` appeared in a condition."
:id "Lint/LiteralInCondition" :checker ruby-rubocop)
'(10 13 info "Do not use `then` for multi-line `if`."
:id "Style/MultilineIfThen" :checker ruby-rubocop)
'(11 7 info "Redundant `return` detected."
:id "Style/RedundantReturn" :checker ruby-rubocop)
'(11 24 error "undefined instance variable @name" :checker ruby-rubylint)
'(16 1 error "wrong number of arguments for 'test' (expected 2..3 but got 0)"
:checker ruby-rubylint)))
(flycheck-ert-def-checker-test ruby-reek ruby warnings
(let ((flycheck-disabled-checkers '(ruby-rubocop ruby-rubylint)))
(flycheck-ert-should-syntax-check
"language/ruby/warnings.rb" 'ruby-mode
'(3 nil warning "Person assumes too much for instance variable '@name'"
:id "InstanceVariableAssumption" :checker ruby-reek))))
(flycheck-ert-def-checker-test ruby ruby warnings
(let ((flycheck-disabled-checkers '(ruby-rubocop ruby-reek ruby-rubylint)))
(flycheck-ert-should-syntax-check
"language/ruby/warnings.rb" 'ruby-mode
'(5 nil warning "assigned but unused variable - arr" :checker ruby)
'(16 nil warning "possibly useless use of == in void context"
:checker ruby))))
(flycheck-ert-def-checker-test ruby-jruby ruby ()
(let ((flycheck-disabled-checkers '(ruby-rubocop ruby-reek ruby-rubylint ruby)))
(flycheck-ert-should-syntax-check
"language/ruby/warnings.rb" 'ruby-mode
'(16 nil warning "Useless use of == in void context."
:checker ruby-jruby))))
(flycheck-ert-def-checker-test rust-cargo rust warning
(let ((flycheck-disabled-checkers '(rust))
(flycheck-rust-crate-type "bin")
(flycheck-rust-binary-name "flycheck-test"))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/warnings.rs" 'rust-mode
'(3 1 warning "function is never used: `main`" :checker rust-cargo)
'(3 1 info "#[warn(dead_code)] on by default" :checker rust-cargo)
'(4 9 warning "unused variable: `x`" :checker rust-cargo)
'(4 9 info "#[warn(unused_variables)] on by default" :checker rust-cargo))))
(flycheck-ert-def-checker-test rust-cargo rust default-target
(let ((flycheck-disabled-checkers '(rust))
(flycheck-rust-crate-type nil)
(flycheck-rust-binary-name nil))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/warnings.rs" 'rust-mode
'(3 1 warning "function is never used: `main`" :checker rust-cargo)
'(3 1 info "#[warn(dead_code)] on by default" :checker rust-cargo)
'(4 9 warning "unused variable: `x`" :checker rust-cargo)
'(4 9 info "#[warn(unused_variables)] on by default" :checker rust-cargo))))
(flycheck-ert-def-checker-test rust-cargo rust lib-main
(let ((flycheck-disabled-checkers '(rust))
(flycheck-rust-crate-type "bin")
(flycheck-rust-binary-name "lib-main"))
(flycheck-ert-should-syntax-check
"language/rust/lib-main/src/main.rs" 'rust-mode)))
(flycheck-ert-def-checker-test rust-cargo rust notes
;; We only get notes on the first build. Ensure we start from a
;; clean directory each time.
(call-process "cargo" nil nil nil "clean" "--manifest-path"
(expand-file-name
"language/rust/note-test/Cargo.toml"
flycheck-test-resources-directory))
(let ((flycheck-disabled-checkers '(rust))
(flycheck-rust-check-tests))
(flycheck-ert-should-syntax-check
"language/rust/note-test/src/lib.rs" 'rust-mode
'(1 1 info "library: util" :checker rust-cargo)
'(1 1 info "library: rt" :checker rust-cargo)
'(1 1 info "library: m" :checker rust-cargo)
'(1 1 info "library: c" :checker rust-cargo)
'(1 1 info "library: gcc_s" :checker rust-cargo)
'(1 1 info "library: pthread" :checker rust-cargo)
'(1 1 info "library: rt" :checker rust-cargo)
'(1 1 info "library: dl" :checker rust-cargo)
'(1 1 info
"the order and any duplication can be significant on some platforms, and so may need to be preserved"
:checker rust-cargo)
'(1 1 info
"link against the following native artifacts when linking against this static library"
:checker rust-cargo))))
(flycheck-ert-def-checker-test rust-cargo rust conventional-layout
(let ((flycheck-disabled-checkers '(rust)))
(let ((flycheck-rust-crate-type "lib"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/src/lib.rs" 'rust-mode
'(3 1 warning "function is never used: `foo_lib`" :checker rust-cargo)
'(3 1 info "#[warn(dead_code)] on by default" :checker rust-cargo)
'(6 17 warning "unused variable: `foo_lib_test`" :checker rust-cargo)
'(6 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)))
(let ((flycheck-rust-crate-type "lib"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/src/a.rs" 'rust-mode
'(1 1 warning "function is never used: `foo_a`" :checker rust-cargo)
'(1 1 info "#[warn(dead_code)] on by default" :checker rust-cargo)
'(4 17 warning "unused variable: `foo_a_test`" :checker rust-cargo)
'(4 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)))
(let ((flycheck-rust-crate-type "bin")
(flycheck-rust-binary-name "cargo-targets"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/src/main.rs" 'rust-mode
'(1 17 warning "unused variable: `foo_main`" :checker rust-cargo)
'(1 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)
'(4 17 warning "unused variable: `foo_main_test`" :checker rust-cargo)
'(4 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)))
(let ((flycheck-rust-crate-type "bin")
(flycheck-rust-binary-name "a"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/src/bin/a.rs" 'rust-mode
'(1 17 warning "unused variable: `foo_bin_a`" :checker rust-cargo)
'(1 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)
'(4 17 warning "unused variable: `foo_bin_a_test`" :checker rust-cargo)
'(4 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)))
(let ((flycheck-rust-crate-type "bench")
(flycheck-rust-binary-name "a"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/benches/a.rs" 'rust-mode
'(1 17 warning "unused variable: `foo_bench_a`" :checker rust-cargo)
'(1 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)
'(4 17 warning "unused variable: `foo_bench_a_test`" :checker rust-cargo)
'(4 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)))
(let ((flycheck-rust-crate-type "test")
(flycheck-rust-binary-name "a"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/tests/a.rs" 'rust-mode
'(2 16 warning "unused variable: `foo_test_a_test`" :checker rust-cargo)
'(2 16 info "#[warn(unused_variables)] on by default" :checker rust-cargo)
'(4 1 warning "function is never used: `foo_test_a`" :checker rust-cargo)
'(4 1 info "#[warn(dead_code)] on by default" :checker rust-cargo)))
(let ((flycheck-rust-crate-type "example")
(flycheck-rust-binary-name "a"))
(flycheck-ert-should-syntax-check
"language/rust/cargo-targets/examples/a.rs" 'rust-mode
'(1 17 warning "unused variable: `foo_ex_a`" :checker rust-cargo)
'(1 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)
'(4 17 warning "unused variable: `foo_ex_a_test`" :checker rust-cargo)
'(4 17 info "#[warn(unused_variables)] on by default" :checker rust-cargo)))))
(flycheck-ert-def-checker-test rust rust syntax-error
(let ((flycheck-disabled-checkers '(rust-cargo)))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/syntax-error.rs" 'rust-mode
'(4 5 error "cannot find value `bla` in this scope (not found in this scope)" :checker rust :id "E0425"))))
(flycheck-ert-def-checker-test rust rust type-error
(let ((flycheck-disabled-checkers '(rust-cargo)))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/multiline-error.rs" 'rust-mode
'(7 9 error "mismatched types (expected u8, found i8)" :checker rust :id "E0308"))))
(flycheck-ert-def-checker-test rust rust warning
(let ((flycheck-disabled-checkers '(rust-cargo)))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/warnings.rs" 'rust-mode
'(4 9 warning "unused variable: `x`" :checker rust)
'(4 9 info "#[warn(unused_variables)] on by default" :checker rust))))
(flycheck-ert-def-checker-test rust rust note-and-help
(let ((flycheck-disabled-checkers '(rust-cargo)))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/note-and-help.rs" 'rust-mode
'(11 9 info "value moved here" :checker rust :id "E0382")
'(12 9 error "use of moved value: `x` (value used here after move)" :checker rust :id "E0382")
'(12 9 info "move occurs because `x` has type `NonPOD`, which does not implement the `Copy` trait" :checker rust :id "E0382"))))
(flycheck-ert-def-checker-test rust rust crate-root-not-set
(let ((flycheck-disabled-checkers '(rust-cargo)))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/importing.rs" 'rust-mode
'(1 5 error "unresolved import `super::imported` (There are too many initial `super`s.)" :checker rust :id "E0432"))))
(flycheck-ert-def-checker-test rust rust macro-error
(let ((flycheck-disabled-checkers '(rust-cargo)))
(flycheck-ert-should-syntax-check
"language/rust/flycheck-test/src/macro-error.rs" 'rust-mode
'(2 3 info "invalid reference to argument `0` (no arguments given)" :checker rust))))
(flycheck-ert-def-checker-test sass sass nil
(flycheck-ert-should-syntax-check
"language/sass/error.sass" 'sass-mode
'(5 nil error "Inconsistent indentation: 3 spaces were used for indentation, but the rest of the document was indented using 2 spaces."
:checker sass)))
(flycheck-ert-def-checker-test sass sass warning
(flycheck-ert-should-syntax-check
"language/sass/warning.sass" 'sass-mode
'(2 nil warning "this is deprecated" :checker sass)))
(flycheck-ert-def-checker-test scala scala nil
(flycheck-ert-should-syntax-check
"language/scala/syntax-error.scala" 'scala-mode
'(3 nil error "identifier expected but '{' found." :checker scala)))
(flycheck-ert-def-checker-test scala-scalastyle scala error
(let ((flycheck-scalastylerc "scalastyle.xml"))
(flycheck-ert-should-syntax-check
"language/scala/style-error.scala" 'scala-mode
'(6 5 error "Don't use println" :checker scala-scalastyle))))
(flycheck-ert-def-checker-test scala-scalastyle scala warning
(let ((flycheck-scalastylerc "scalastyle.xml"))
(flycheck-ert-should-syntax-check
"language/scala/style-warning.scala" 'scala-mode
'(5 9 warning "Redundant braces after class definition"
:checker scala-scalastyle))))
(defvar geiser-impl--implementation)
(defun flycheck/chicken-mode ()
"Enable Scheme and Geiser mode for Chicken scheme."
(interactive)
(scheme-mode)
(setq-local geiser-impl--implementation 'chicken)
(geiser-mode))
(flycheck-ert-def-checker-test scheme-chicken scheme nil
(flycheck-ert-should-syntax-check
"language/chicken/error.scm" 'flycheck/chicken-mode
'(2 nil warning "in procedure call to `g1', expected a value of type `(procedure (* *) *)' but was given a value of type `number'"
:checker scheme-chicken)))
(flycheck-ert-def-checker-test scheme-chicken scheme syntax-error
(flycheck-ert-should-syntax-check
"language/chicken/syntax-error.scm" 'flycheck/chicken-mode
'(1 nil error "not enough arguments\n\n\t(define)\n\n\tExpansion history:\n\n\t<syntax>\t (##core#begin (define))\n\t<syntax>\t (define)\t<--"
:checker scheme-chicken)))
(flycheck-ert-def-checker-test scheme-chicken scheme syntax-read-error
(flycheck-ert-should-syntax-check
"language/chicken/syntax-read-error.scm" 'flycheck/chicken-mode
'(1 nil error "invalid sharp-sign read syntax: #\\n"
:checker scheme-chicken)))
(flycheck-ert-def-checker-test scss-lint scss nil
(let ((flycheck-scss-lintrc "scss-lint.yml"))
(flycheck-ert-should-syntax-check
"language/scss/lint-error.scss" 'scss-mode
'(1 1 error "Avoid using id selectors"
:checker scss-lint :id "IdSelector")
'(3 16 warning "Color `red` should be written in hexadecimal form as `#ff0000`"
:checker scss-lint :id "ColorKeyword"))))
(flycheck-ert-def-checker-test scss-lint scss syntax-error
(flycheck-ert-should-syntax-check
"language/scss/error.scss" 'scss-mode
'(3 1 error "Syntax Error: Invalid CSS after \"... c olor: red\": expected \"{\", was \";\""
:checker scss-lint)))
(flycheck-ert-def-checker-test scss scss nil
(let ((flycheck-disabled-checkers '(scss-lint)))
(flycheck-ert-should-syntax-check
"language/scss/error.scss" 'scss-mode
'(3 nil error "Invalid CSS after \"... c olor: red\": expected \"{\", was \";\""
:checker scss))))
(flycheck-ert-def-checker-test scss scss warning
(let ((flycheck-disabled-checkers '(scss-lint)))
(flycheck-ert-should-syntax-check
"language/scss/warning.scss" 'scss-mode
'(2 nil warning ".container is deprecated" :checker scss))))
(flycheck-ert-def-checker-test sh-bash (sh sh-bash) nil
(flycheck-ert-should-syntax-check
"language/sh/bash-syntax-error.bash" 'sh-mode
'(5 nil error "syntax error near unexpected token `fi'" :checker sh-bash)
'(5 nil error "`fi'" :checker sh-bash)))
(flycheck-ert-def-checker-test sh-posix-dash (sh sh-posix) nil
(flycheck-ert-should-syntax-check
"language/sh/posix-syntax-error.sh" 'sh-mode
'(3 nil error "Syntax error: \"(\" unexpected" :checker sh-posix-dash)))
(flycheck-ert-def-checker-test sh-posix-bash (sh sh-posix) nil
(let ((flycheck-disabled-checkers '(sh-posix-dash)))
(flycheck-ert-should-syntax-check
"language/sh/posix-syntax-error.sh" 'sh-mode
'(3 nil error "syntax error near unexpected token `('"
:checker sh-posix-bash)
'(3 nil error "`cat <(echo blah)'" :checker sh-posix-bash))))
(flycheck-ert-def-checker-test sh-zsh (sh sh-zsh) nil
(flycheck-ert-should-syntax-check
"language/sh/zsh-syntax-error.zsh" 'sh-mode
'(5 nil error "parse error near `fi'" :checker sh-zsh)))
(flycheck-ert-def-checker-test sh-shellcheck sh nil
:tags '(checkstyle-xml)
(flycheck-ert-should-syntax-check
"language/sh/shellcheck.sh" 'sh-mode
'(2 5 warning "Tilde does not expand in quotes. Use $HOME."
:checker sh-shellcheck :id "SC2088")
'(3 7 error "Double quote array expansions to avoid re-splitting elements."
:checker sh-shellcheck :id "SC2068")
'(4 8 warning "Declare and assign separately to avoid masking return values."
:checker sh-shellcheck :id "SC2155")
'(4 11 info "Use $(..) instead of legacy `..`."
:checker sh-shellcheck :id "SC2006")))
(flycheck-ert-def-checker-test slim slim nil
(flycheck-ert-should-syntax-check
"language/slim.slim" 'slim-mode
`(2 1 error "Unexpected indentation" :checker slim)))
(flycheck-ert-def-checker-test sqlint sql nil
(flycheck-ert-should-syntax-check
"language/sql.sql" 'sql-mode
`(1 15 error "unterminated quoted string at or near \"';\n \""
:checker sql-sqlint)))
(flycheck-ert-def-checker-test systemd-analyze systemd nil
(flycheck-ert-should-syntax-check
"language/systemd-analyze-test.service" 'systemd-mode
'(3 nil error "Invalid URL, ignoring: foo://bar"
:checker systemd-analyze)
'(6 nil error "Unknown lvalue 'ExecSmart' in section 'Service'"
:checker systemd-analyze)
'(8 nil error "Unknown section 'Dog'. Ignoring."
:checker systemd-analyze)))
(flycheck-ert-def-checker-test tex-chktex (tex latex) nil
(flycheck-ert-should-syntax-check
"language/tex.tex" 'latex-mode
'(5 29 warning "Intersentence spacing (`\\@') should perhaps be used."
:id "13" :checker tex-chktex)))
(flycheck-ert-def-checker-test tex-lacheck (tex latex) nil
(let ((flycheck-disabled-checkers '(tex-chktex)))
(flycheck-ert-should-syntax-check
"language/tex.tex" 'latex-mode
'(5 nil warning "missing `\\@' before `.' in \"GNU.\""
:checker tex-lacheck)
'(7 nil warning "possible unwanted space at \"{\""
:checker tex-lacheck))))
(flycheck-ert-def-checker-test texinfo texinfo nil
(flycheck-ert-should-syntax-check
"language/texinfo.texi" 'texinfo-mode
'(3 nil warning "@settitle missing argument" :checker texinfo)
'(7 nil error "unknown command `bold'" :checker texinfo)
'(7 nil error "misplaced {" :checker texinfo)
'(7 nil error "misplaced }" :checker texinfo)
'(9 nil warning "printindex before document beginning: @printindex cp"
:checker texinfo)))
(flycheck-ert-def-checker-test typescript-tslint typescript nil
(flycheck-ert-should-syntax-check
"language/typescript/sample.ts" 'typescript-mode
'(1 10 warning "Unused function: 'invalidAlignment'"
:checker typescript-tslint :id "no-unused-variable")
'(2 3 warning "Forbidden 'var' keyword, use 'let' or 'const' instead"
:checker typescript-tslint :id "no-var-keyword")
'(2 7 warning "Unused variable: 'a'"
:checker typescript-tslint :id "no-unused-variable")
'(3 15 warning "Missing semicolon"
:checker typescript-tslint :id "semicolon")))
(flycheck-ert-def-checker-test verilog-verilator verilog error
(flycheck-ert-should-syntax-check
"language/verilog/verilator_error.v" 'verilog-mode
'(4 nil error "Unsupported: $fopen with multichannel descriptor. Add ,\"w\" as second argument to open a file descriptor."
:checker verilog-verilator)))
(flycheck-ert-def-checker-test verilog-verilator verilog warning
(flycheck-ert-should-syntax-check
"language/verilog/verilator_warning.v" 'verilog-mode
'(2 nil warning "Signal is not driven, nor used: val"
:checker verilog-verilator)))
(flycheck-ert-def-checker-test xml-xmlstarlet xml nil
(flycheck-ert-should-syntax-check
"language/xml.xml" 'nxml-mode
'(4 10 error "Opening and ending tag mismatch: spam line 3 and with"
:checker xml-xmlstarlet)))
(flycheck-ert-def-checker-test xml-xmllint xml nil
(let ((flycheck-disabled-checkers '(xml-xmlstarlet)))
(flycheck-ert-should-syntax-check
"language/xml.xml" 'nxml-mode
'(4 nil error "parser error : Opening and ending tag mismatch: spam line 3 and with"
:checker xml-xmllint)
'(5 nil error "parser error : Extra content at the end of the document"
:checker xml-xmllint))))
(flycheck-ert-def-checker-test yaml-jsyaml yaml nil
(flycheck-ert-should-syntax-check
"language/yaml.yaml" 'yaml-mode
'(4 5 error "bad indentation of a mapping entry"
:checker yaml-jsyaml)))
(flycheck-ert-def-checker-test yaml-ruby yaml nil
(let ((flycheck-disabled-checkers '(yaml-jsyaml)))
(flycheck-ert-should-syntax-check
"language/yaml.yaml" 'yaml-mode
'(4 5 error "mapping values are not allowed in this context"
:checker yaml-ruby))))
(flycheck-ert-initialize flycheck-test-resources-directory)
(provide 'flycheck-test)
;; Local Variables:
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
;;; flycheck-test.el ends here
|