dte test coverage


Directory: ./
File: src/filetype/interpreters.c
Date: 2025-02-14 16:55:22
Exec Total Coverage
Lines: 9 9 100.0%
Functions: 1 1 100.0%
Branches: 12 12 100.0%

Line Branch Exec Source
1 static const struct FileInterpreterMap {
2 const char key[8];
3 const FileTypeEnum filetype;
4 } interpreters[] = {
5 {"ash", SH},
6 {"awk", AWK},
7 {"bash", SH},
8 {"bats", SH}, // https://github.com/bats-core/bats-core
9 {"bigloo", SCHEME},
10 {"ccl", LISP},
11 {"chicken", SCHEME},
12 {"clisp", LISP},
13 {"coffee", COFFEESCRIPT},
14 {"crystal", RUBY},
15 {"csh", CSH},
16 {"dart", DART},
17 {"dash", SH},
18 {"deno", TYPESCRIPT},
19 {"ecl", LISP},
20 {"elixir", ELIXIR},
21 {"escript", ERLANG},
22 {"fish", FISH},
23 {"gawk", AWK},
24 {"gjs", JAVASCRIPT},
25 {"gmake", MAKE},
26 {"gnuplot", GNUPLOT},
27 {"groovy", GROOVY},
28 {"gsed", SED},
29 {"guile", SCHEME},
30 {"jruby", RUBY},
31 {"julia", JULIA},
32 {"ksh", SH},
33 {"lisp", LISP},
34 {"lua", LUA},
35 {"luajit", LUA},
36 {"macruby", RUBY},
37 {"make", MAKE},
38 {"mawk", AWK},
39 {"mksh", SH},
40 {"moon", MOONSCRIPT},
41 {"nawk", AWK},
42 {"nft", NFTABLES},
43 {"node", JAVASCRIPT},
44 {"nodejs", JAVASCRIPT},
45 {"ocaml", OCAML},
46 {"pdksh", SH},
47 {"perl", PERL},
48 {"php", PHP},
49 {"pwsh", POWERSHELL},
50 {"pypy", PYTHON},
51 {"python", PYTHON},
52 {"qjs", JAVASCRIPT},
53 {"r6rs", SCHEME},
54 {"racket", SCHEME},
55 {"rake", RUBY},
56 {"rbx", RUBY},
57 {"ruby", RUBY},
58 {"runghc", HASKELL},
59 {"sbcl", LISP},
60 {"scala", SCALA},
61 {"scheme", SCHEME},
62 {"sed", SED},
63 {"sh", SH},
64 {"tcc", C},
65 {"tclsh", TCL},
66 {"tcsh", CSH},
67 {"ts-node", TYPESCRIPT},
68 {"wish", TCL},
69 {"zsh", SH},
70 };
71
72 274 static FileTypeEnum filetype_from_interpreter(const StringView name)
73 {
74
2/2
✓ Branch 0 (2→3) taken 64 times.
✓ Branch 1 (2→14) taken 210 times.
274 if (name.length < 2) {
75 return NONE;
76 }
77
78
2/2
✓ Branch 0 (3→4) taken 5 times.
✓ Branch 1 (3→11) taken 59 times.
64 if (name.length >= ARRAYLEN(interpreters[0].key)) {
79
2/2
✓ Branch 0 (5→6) taken 4 times.
✓ Branch 1 (5→14) taken 1 times.
5 if (strview_equal_cstring(&name, "openrc-run")) {
80 return SH;
81
2/2
✓ Branch 0 (7→8) taken 3 times.
✓ Branch 1 (7→14) taken 1 times.
4 } else if (strview_equal_cstring(&name, "runhaskell")) {
82 return HASKELL;
83
2/2
✓ Branch 0 (9→10) taken 2 times.
✓ Branch 1 (9→14) taken 1 times.
3 } else if (strview_equal_cstring(&name, "rust-script")) {
84 return RUST;
85 }
86 2 return NONE;
87 }
88
89 59 const struct FileInterpreterMap *e = BSEARCH(&name, interpreters, ft_compare);
90
2/2
✓ Branch 0 (12→13) taken 56 times.
✓ Branch 1 (12→14) taken 3 times.
59 return e ? e->filetype : NONE;
91 }
92