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
mod common;
use common::sqry_bin;
use assert_cmd::Command;
use std::fs;
use std::path::Path;
use tempfile::TempDir;
fn sqry_cmd() -> Command {
let path = sqry_bin();
let mut cmd = Command::new(path);
cmd.env("NO_COLOR", "1");
cmd
}
fn write_file(dir: &Path, name: &str, content: &str) {
fs::create_dir_all(dir).unwrap();
fs::write(dir.join(name), content).unwrap();
}
/// End-to-end smoke test: ensure `lang:` filters are accepted for all
/// built-in languages registered by the CLI in workspace mode.
///
/// This test does NOT assert specific symbols for every language; instead it
/// verifies that:
/// - each language has at least one indexed file in the workspace
/// - `sqry workspace query . "lang:<id>"` succeeds without parse/validation errors
///
/// This guards against regressions where the `lang` field validation or
/// workspace query path rejects certain language IDs.
#[test]
#[allow(clippy::too_many_lines)] // Tests all 37 language plugins end-to-end
fn workspace_lang_filter_smoke_for_all_languages() {
let workspace_dir = TempDir::new().unwrap();
let workspace_path = workspace_dir.path();
// Initialize workspace once
sqry_cmd()
.args(["workspace", "init", workspace_path.to_str().unwrap()])
.assert()
.success();
// Each entry: (language id, directory name, filename, file contents)
let languages: &[(&str, &str, &str, &str)] = &[
// General-purpose languages
(
"c",
"c-service",
"main.c",
"int add(int a, int b) { return a + b; }\n",
),
(
"cpp",
"cpp-service",
"main.cpp",
"int add(int a, int b) { return a + b; }\n",
),
(
"csharp",
"csharp-service",
"Program.cs",
"class Program { static void Main() {} }\n",
),
("css", "css-service", "styles.css", "body { color: red; }\n"),
(
"dart",
"dart-service",
"main.dart",
"int add(int a, int b) => a + b;\n",
),
(
"elixir",
"elixir-service",
"app.ex",
"defmodule App do\n def run, do: :ok\nend\n",
),
(
"go",
"go-service",
"main.go",
"package main\n\nfunc main() {}\n",
),
(
"groovy",
"groovy-service",
"App.groovy",
"class App { static void main(String[] args) { println 'hi' } }\n",
),
(
"haskell",
"haskell-service",
"Main.hs",
"module Main where\n\nmain :: IO ()\nmain = pure ()\n",
),
(
"html",
"html-service",
"index.html",
"<!doctype html><html><body><h1>Hi</h1></body></html>\n",
),
(
"java",
"java-service",
"App.java",
"public class App { public static void main(String[] args) {} }\n",
),
(
"javascript",
"javascript-service",
"app.js",
"function main() { console.log('hi'); }\nmain();\n",
),
(
"kotlin",
"kotlin-service",
"App.kt",
"fun main() { println(\"hi\") }\n",
),
(
"lua",
"lua-service",
"app.lua",
"local function main() end\nmain()\n",
),
(
"perl",
"perl-service",
"app.pl",
"sub main { return 0; }\nmain();\n",
),
(
"php",
"php-service",
"app.php",
"<?php function main() {} main();\n",
),
(
"python",
"python-service",
"app.py",
"def main():\n return 0\n\nmain()\n",
),
(
"r",
"r-service",
"app.r",
"main <- function() { 1 }\nmain()\n",
),
(
"ruby",
"ruby-service",
"app.rb",
"def main\n puts 'hi'\nend\n\nmain\n",
),
(
"rust",
"rust-service",
"main.rs",
"fn main() { println!(\"hi\"); }\n",
),
(
"scala",
"scala-service",
"App.scala",
"object App { def main(args: Array[String]): Unit = () }\n",
),
(
"shell",
"shell-service",
"app.sh",
"#!/usr/bin/env bash\nmain() { echo hi; }\nmain\n",
),
(
"sql",
"sql-service",
"schema.sql",
"CREATE TABLE users(id INT);\n",
),
(
"svelte",
"svelte-service",
"App.svelte",
"<script>let x = 1;</script><h1>{x}</h1>\n",
),
(
"swift",
"swift-service",
"main.swift",
"func main() { print(\"hi\") }\nmain()\n",
),
(
"typescript",
"typescript-service",
"app.ts",
"function main(): void { console.log('hi'); }\nmain();\n",
),
(
"vue",
"vue-service",
"App.vue",
"<template><div>Hi</div></template><script>export default {}</script>\n",
),
(
"zig",
"zig-service",
"main.zig",
"pub fn main() !void { }\n",
),
// Domain-specific plugins
(
"plsql",
"plsql-service",
"package.pks",
"CREATE OR REPLACE PACKAGE demo AS END demo;\n",
),
(
"apex",
"apex-service",
"Demo.cls",
"public class Demo { public static void run() {} }\n",
),
(
"abap",
"abap-service",
"demo.abap",
"REPORT z_demo.\nWRITE 'hi'.\n",
),
(
"servicenow-xanadu-js",
"servicenow-service",
"script.snjs",
"class App {}\nvar x = function() { return 1; };\n",
),
];
// Index each language-specific repo and add it to the workspace
for (lang_id, dir_name, file_name, contents) in languages {
let repo_dir = workspace_path.join(dir_name);
write_file(&repo_dir, file_name, contents);
// Index repository
sqry_cmd()
.args(["index", repo_dir.to_str().unwrap()])
.assert()
.success();
// Add to workspace
sqry_cmd()
.args([
"workspace",
"add",
workspace_path.to_str().unwrap(),
repo_dir.to_str().unwrap(),
])
.assert()
.success();
// Sanity check: lang:<id> query must be accepted and not fail validation
let query = format!("lang:{lang_id}");
sqry_cmd()
.args([
"workspace",
"query",
workspace_path.to_str().unwrap(),
&query,
])
.assert()
.success();
}
}