|
| 1 | +# ============================================================ |
| 2 | +# Functional tests for Linguist known files |
| 3 | +# Verifies that extensionless files are auto-detected by type |
| 4 | +# ============================================================ |
| 5 | + |
| 6 | +# YAML known files |
| 7 | +exec validator .clang-format |
| 8 | +stdout '✓' |
| 9 | + |
| 10 | +exec validator .clang-tidy |
| 11 | +stdout '✓' |
| 12 | + |
| 13 | +exec validator .clangd |
| 14 | +stdout '✓' |
| 15 | + |
| 16 | +exec validator .gemrc |
| 17 | +stdout '✓' |
| 18 | + |
| 19 | +# INI known files |
| 20 | +exec validator .gitconfig |
| 21 | +stdout '✓' |
| 22 | + |
| 23 | +exec validator .npmrc |
| 24 | +stdout '✓' |
| 25 | + |
| 26 | +exec validator .shellcheckrc |
| 27 | +stdout '✓' |
| 28 | + |
| 29 | +# JSON known files |
| 30 | +exec validator .arcconfig |
| 31 | +stdout '✓' |
| 32 | + |
| 33 | +exec validator composer.lock |
| 34 | +stdout '✓' |
| 35 | + |
| 36 | +# JSONC known files |
| 37 | +exec validator .babelrc |
| 38 | +stdout '✓' |
| 39 | + |
| 40 | +exec validator tsconfig.json |
| 41 | +stdout '✓' |
| 42 | + |
| 43 | +# TOML known files |
| 44 | +exec validator Pipfile |
| 45 | +stdout '✓' |
| 46 | + |
| 47 | +# XML known files |
| 48 | +exec validator pom.xml |
| 49 | +stdout '✓' |
| 50 | + |
| 51 | +# Invalid known files should fail |
| 52 | +! exec validator invalid/.clang-format |
| 53 | +stdout '×' |
| 54 | + |
| 55 | +! exec validator invalid/.babelrc |
| 56 | +stdout '×' |
| 57 | + |
| 58 | +# Unknown extensionless files should be ignored (exit 0, no output) |
| 59 | +exec validator unknown |
| 60 | +! stdout '.' |
| 61 | + |
| 62 | +# ============================================================ |
| 63 | +# SchemaStore with extensionless known files |
| 64 | +# ============================================================ |
| 65 | + |
| 66 | +# .babelrc valid against schema |
| 67 | +exec validator --schemastore-path schemastore .babelrc |
| 68 | +stdout '✓' |
| 69 | + |
| 70 | +# .babelrc invalid against schema (additionalProperties: false) |
| 71 | +! exec validator --schemastore-path schemastore invalid-schema/.babelrc |
| 72 | +stdout '×' |
| 73 | +stdout 'error:' |
| 74 | + |
| 75 | +# .clangd valid against schema |
| 76 | +exec validator --schemastore-path schemastore .clangd |
| 77 | +stdout '✓' |
| 78 | + |
| 79 | +# ============================================================ |
| 80 | +# Valid known files |
| 81 | +# ============================================================ |
| 82 | + |
| 83 | +-- .clang-format -- |
| 84 | +BasedOnStyle: LLVM |
| 85 | +IndentWidth: 4 |
| 86 | +-- .clang-tidy -- |
| 87 | +Checks: '-*,readability-*' |
| 88 | +-- .clangd -- |
| 89 | +CompileFlags: |
| 90 | + Add: [-Wall] |
| 91 | +-- .gemrc -- |
| 92 | +gem: --no-document |
| 93 | +-- .gitconfig -- |
| 94 | +[user] |
| 95 | +name=test |
| 96 | +email=test@example.com |
| 97 | +-- .npmrc -- |
| 98 | +registry=https://registry.npmjs.org/ |
| 99 | +-- .shellcheckrc -- |
| 100 | +disable=SC2034 |
| 101 | +-- .arcconfig -- |
| 102 | +{"project_id": "myproject"} |
| 103 | +-- composer.lock -- |
| 104 | +{"packages": [], "_readme": ["This file locks the dependencies"]} |
| 105 | +-- .babelrc -- |
| 106 | +{"presets": ["env"]} |
| 107 | +-- tsconfig.json -- |
| 108 | +// TypeScript config |
| 109 | +{"compilerOptions": {"strict": true}} |
| 110 | +-- Pipfile -- |
| 111 | +[packages] |
| 112 | +requests = "*" |
| 113 | +-- pom.xml -- |
| 114 | +<project><modelVersion>4.0.0</modelVersion></project> |
| 115 | +-- unknown -- |
| 116 | +this is not a config file |
| 117 | + |
| 118 | +# ============================================================ |
| 119 | +# Invalid known files |
| 120 | +# ============================================================ |
| 121 | + |
| 122 | +-- invalid/.clang-format -- |
| 123 | +BasedOnStyle: LLVM |
| 124 | + bad indentation: |
| 125 | + - this: is broken |
| 126 | + :::::: |
| 127 | +-- invalid/.babelrc -- |
| 128 | +{"bad": } |
| 129 | + |
| 130 | +# ============================================================ |
| 131 | +# SchemaStore invalid files |
| 132 | +# ============================================================ |
| 133 | + |
| 134 | +-- invalid-schema/.babelrc -- |
| 135 | +{"presets": ["env"], "unknown_field": true} |
| 136 | + |
| 137 | +# ============================================================ |
| 138 | +# Mini SchemaStore bundle with extensionless entries |
| 139 | +# ============================================================ |
| 140 | + |
| 141 | +-- schemastore/src/api/json/catalog.json -- |
| 142 | +{ |
| 143 | + "schemas": [ |
| 144 | + { |
| 145 | + "name": "Babel", |
| 146 | + "fileMatch": [".babelrc"], |
| 147 | + "url": "https://www.schemastore.org/babelrc.json" |
| 148 | + }, |
| 149 | + { |
| 150 | + "name": "clangd", |
| 151 | + "fileMatch": [".clangd"], |
| 152 | + "url": "https://www.schemastore.org/clangd.json" |
| 153 | + } |
| 154 | + ] |
| 155 | +} |
| 156 | +-- schemastore/src/schemas/json/babelrc.json -- |
| 157 | +{ |
| 158 | + "type": "object", |
| 159 | + "properties": { |
| 160 | + "presets": { "type": "array", "items": { "type": "string" } }, |
| 161 | + "plugins": { "type": "array" } |
| 162 | + }, |
| 163 | + "additionalProperties": false |
| 164 | +} |
| 165 | +-- schemastore/src/schemas/json/clangd.json -- |
| 166 | +{ |
| 167 | + "type": "object", |
| 168 | + "properties": { |
| 169 | + "CompileFlags": { "type": "object" }, |
| 170 | + "Diagnostics": { "type": "object" }, |
| 171 | + "InlayHints": { "type": "object" } |
| 172 | + } |
| 173 | +} |
0 commit comments