@hasna/terminal 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +64 -16
- package/package.json +1 -1
- package/src/ai.ts +8 -0
- package/src/cli.tsx +57 -18
- package/src/output-processor.ts +6 -1
- package/src/output-store.ts +58 -12
- package/src/tool-profiles.ts +139 -0
- package/temp/rtk/.claude/agents/code-reviewer.md +0 -221
- package/temp/rtk/.claude/agents/debugger.md +0 -519
- package/temp/rtk/.claude/agents/rtk-testing-specialist.md +0 -461
- package/temp/rtk/.claude/agents/rust-rtk.md +0 -511
- package/temp/rtk/.claude/agents/technical-writer.md +0 -355
- package/temp/rtk/.claude/commands/diagnose.md +0 -352
- package/temp/rtk/.claude/commands/test-routing.md +0 -362
- package/temp/rtk/.claude/hooks/bash/pre-commit-format.sh +0 -16
- package/temp/rtk/.claude/hooks/rtk-rewrite.sh +0 -70
- package/temp/rtk/.claude/hooks/rtk-suggest.sh +0 -152
- package/temp/rtk/.claude/rules/cli-testing.md +0 -526
- package/temp/rtk/.claude/skills/issue-triage/SKILL.md +0 -348
- package/temp/rtk/.claude/skills/issue-triage/templates/issue-comment.md +0 -134
- package/temp/rtk/.claude/skills/performance.md +0 -435
- package/temp/rtk/.claude/skills/pr-triage/SKILL.md +0 -315
- package/temp/rtk/.claude/skills/pr-triage/templates/review-comment.md +0 -71
- package/temp/rtk/.claude/skills/repo-recap.md +0 -206
- package/temp/rtk/.claude/skills/rtk-tdd/SKILL.md +0 -78
- package/temp/rtk/.claude/skills/rtk-tdd/references/testing-patterns.md +0 -124
- package/temp/rtk/.claude/skills/security-guardian.md +0 -503
- package/temp/rtk/.claude/skills/ship.md +0 -404
- package/temp/rtk/.github/workflows/benchmark.yml +0 -34
- package/temp/rtk/.github/workflows/dco-check.yaml +0 -12
- package/temp/rtk/.github/workflows/release-please.yml +0 -51
- package/temp/rtk/.github/workflows/release.yml +0 -343
- package/temp/rtk/.github/workflows/security-check.yml +0 -135
- package/temp/rtk/.github/workflows/validate-docs.yml +0 -78
- package/temp/rtk/.release-please-manifest.json +0 -3
- package/temp/rtk/ARCHITECTURE.md +0 -1491
- package/temp/rtk/CHANGELOG.md +0 -640
- package/temp/rtk/CLAUDE.md +0 -605
- package/temp/rtk/CONTRIBUTING.md +0 -199
- package/temp/rtk/Cargo.lock +0 -1668
- package/temp/rtk/Cargo.toml +0 -64
- package/temp/rtk/Formula/rtk.rb +0 -43
- package/temp/rtk/INSTALL.md +0 -390
- package/temp/rtk/LICENSE +0 -21
- package/temp/rtk/README.md +0 -386
- package/temp/rtk/README_es.md +0 -159
- package/temp/rtk/README_fr.md +0 -197
- package/temp/rtk/README_ja.md +0 -159
- package/temp/rtk/README_ko.md +0 -159
- package/temp/rtk/README_zh.md +0 -167
- package/temp/rtk/ROADMAP.md +0 -15
- package/temp/rtk/SECURITY.md +0 -217
- package/temp/rtk/TEST_EXEC_TIME.md +0 -102
- package/temp/rtk/build.rs +0 -57
- package/temp/rtk/docs/AUDIT_GUIDE.md +0 -432
- package/temp/rtk/docs/FEATURES.md +0 -1410
- package/temp/rtk/docs/TROUBLESHOOTING.md +0 -309
- package/temp/rtk/docs/filter-workflow.md +0 -102
- package/temp/rtk/docs/images/gain-dashboard.jpg +0 -0
- package/temp/rtk/docs/tracking.md +0 -583
- package/temp/rtk/hooks/opencode-rtk.ts +0 -39
- package/temp/rtk/hooks/rtk-awareness.md +0 -29
- package/temp/rtk/hooks/rtk-rewrite.sh +0 -61
- package/temp/rtk/hooks/test-rtk-rewrite.sh +0 -442
- package/temp/rtk/install.sh +0 -124
- package/temp/rtk/release-please-config.json +0 -10
- package/temp/rtk/scripts/benchmark.sh +0 -592
- package/temp/rtk/scripts/check-installation.sh +0 -162
- package/temp/rtk/scripts/install-local.sh +0 -37
- package/temp/rtk/scripts/rtk-economics.sh +0 -137
- package/temp/rtk/scripts/test-all.sh +0 -561
- package/temp/rtk/scripts/test-aristote.sh +0 -227
- package/temp/rtk/scripts/test-tracking.sh +0 -79
- package/temp/rtk/scripts/update-readme-metrics.sh +0 -32
- package/temp/rtk/scripts/validate-docs.sh +0 -73
- package/temp/rtk/src/aws_cmd.rs +0 -880
- package/temp/rtk/src/binlog.rs +0 -1645
- package/temp/rtk/src/cargo_cmd.rs +0 -1727
- package/temp/rtk/src/cc_economics.rs +0 -1157
- package/temp/rtk/src/ccusage.rs +0 -340
- package/temp/rtk/src/config.rs +0 -187
- package/temp/rtk/src/container.rs +0 -855
- package/temp/rtk/src/curl_cmd.rs +0 -134
- package/temp/rtk/src/deps.rs +0 -268
- package/temp/rtk/src/diff_cmd.rs +0 -367
- package/temp/rtk/src/discover/mod.rs +0 -274
- package/temp/rtk/src/discover/provider.rs +0 -388
- package/temp/rtk/src/discover/registry.rs +0 -2022
- package/temp/rtk/src/discover/report.rs +0 -202
- package/temp/rtk/src/discover/rules.rs +0 -667
- package/temp/rtk/src/display_helpers.rs +0 -402
- package/temp/rtk/src/dotnet_cmd.rs +0 -1771
- package/temp/rtk/src/dotnet_format_report.rs +0 -133
- package/temp/rtk/src/dotnet_trx.rs +0 -593
- package/temp/rtk/src/env_cmd.rs +0 -204
- package/temp/rtk/src/filter.rs +0 -462
- package/temp/rtk/src/filters/README.md +0 -52
- package/temp/rtk/src/filters/ansible-playbook.toml +0 -34
- package/temp/rtk/src/filters/basedpyright.toml +0 -47
- package/temp/rtk/src/filters/biome.toml +0 -45
- package/temp/rtk/src/filters/brew-install.toml +0 -37
- package/temp/rtk/src/filters/composer-install.toml +0 -40
- package/temp/rtk/src/filters/df.toml +0 -16
- package/temp/rtk/src/filters/dotnet-build.toml +0 -64
- package/temp/rtk/src/filters/du.toml +0 -16
- package/temp/rtk/src/filters/fail2ban-client.toml +0 -15
- package/temp/rtk/src/filters/gcc.toml +0 -49
- package/temp/rtk/src/filters/gcloud.toml +0 -22
- package/temp/rtk/src/filters/hadolint.toml +0 -24
- package/temp/rtk/src/filters/helm.toml +0 -29
- package/temp/rtk/src/filters/iptables.toml +0 -27
- package/temp/rtk/src/filters/jj.toml +0 -28
- package/temp/rtk/src/filters/jq.toml +0 -24
- package/temp/rtk/src/filters/make.toml +0 -41
- package/temp/rtk/src/filters/markdownlint.toml +0 -24
- package/temp/rtk/src/filters/mix-compile.toml +0 -27
- package/temp/rtk/src/filters/mix-format.toml +0 -15
- package/temp/rtk/src/filters/mvn-build.toml +0 -44
- package/temp/rtk/src/filters/oxlint.toml +0 -43
- package/temp/rtk/src/filters/ping.toml +0 -63
- package/temp/rtk/src/filters/pio-run.toml +0 -40
- package/temp/rtk/src/filters/poetry-install.toml +0 -50
- package/temp/rtk/src/filters/pre-commit.toml +0 -35
- package/temp/rtk/src/filters/ps.toml +0 -16
- package/temp/rtk/src/filters/quarto-render.toml +0 -41
- package/temp/rtk/src/filters/rsync.toml +0 -48
- package/temp/rtk/src/filters/shellcheck.toml +0 -27
- package/temp/rtk/src/filters/shopify-theme.toml +0 -29
- package/temp/rtk/src/filters/skopeo.toml +0 -45
- package/temp/rtk/src/filters/sops.toml +0 -16
- package/temp/rtk/src/filters/ssh.toml +0 -44
- package/temp/rtk/src/filters/stat.toml +0 -34
- package/temp/rtk/src/filters/swift-build.toml +0 -41
- package/temp/rtk/src/filters/systemctl-status.toml +0 -33
- package/temp/rtk/src/filters/terraform-plan.toml +0 -35
- package/temp/rtk/src/filters/tofu-fmt.toml +0 -16
- package/temp/rtk/src/filters/tofu-init.toml +0 -38
- package/temp/rtk/src/filters/tofu-plan.toml +0 -35
- package/temp/rtk/src/filters/tofu-validate.toml +0 -17
- package/temp/rtk/src/filters/trunk-build.toml +0 -39
- package/temp/rtk/src/filters/ty.toml +0 -50
- package/temp/rtk/src/filters/uv-sync.toml +0 -37
- package/temp/rtk/src/filters/xcodebuild.toml +0 -99
- package/temp/rtk/src/filters/yamllint.toml +0 -25
- package/temp/rtk/src/find_cmd.rs +0 -598
- package/temp/rtk/src/format_cmd.rs +0 -386
- package/temp/rtk/src/gain.rs +0 -723
- package/temp/rtk/src/gh_cmd.rs +0 -1651
- package/temp/rtk/src/git.rs +0 -2012
- package/temp/rtk/src/go_cmd.rs +0 -592
- package/temp/rtk/src/golangci_cmd.rs +0 -254
- package/temp/rtk/src/grep_cmd.rs +0 -288
- package/temp/rtk/src/gt_cmd.rs +0 -810
- package/temp/rtk/src/hook_audit_cmd.rs +0 -283
- package/temp/rtk/src/hook_check.rs +0 -171
- package/temp/rtk/src/init.rs +0 -1859
- package/temp/rtk/src/integrity.rs +0 -537
- package/temp/rtk/src/json_cmd.rs +0 -231
- package/temp/rtk/src/learn/detector.rs +0 -628
- package/temp/rtk/src/learn/mod.rs +0 -119
- package/temp/rtk/src/learn/report.rs +0 -184
- package/temp/rtk/src/lint_cmd.rs +0 -694
- package/temp/rtk/src/local_llm.rs +0 -316
- package/temp/rtk/src/log_cmd.rs +0 -248
- package/temp/rtk/src/ls.rs +0 -324
- package/temp/rtk/src/main.rs +0 -2482
- package/temp/rtk/src/mypy_cmd.rs +0 -389
- package/temp/rtk/src/next_cmd.rs +0 -241
- package/temp/rtk/src/npm_cmd.rs +0 -236
- package/temp/rtk/src/parser/README.md +0 -267
- package/temp/rtk/src/parser/error.rs +0 -46
- package/temp/rtk/src/parser/formatter.rs +0 -336
- package/temp/rtk/src/parser/mod.rs +0 -311
- package/temp/rtk/src/parser/types.rs +0 -119
- package/temp/rtk/src/pip_cmd.rs +0 -302
- package/temp/rtk/src/playwright_cmd.rs +0 -479
- package/temp/rtk/src/pnpm_cmd.rs +0 -573
- package/temp/rtk/src/prettier_cmd.rs +0 -221
- package/temp/rtk/src/prisma_cmd.rs +0 -482
- package/temp/rtk/src/psql_cmd.rs +0 -382
- package/temp/rtk/src/pytest_cmd.rs +0 -384
- package/temp/rtk/src/read.rs +0 -217
- package/temp/rtk/src/rewrite_cmd.rs +0 -50
- package/temp/rtk/src/ruff_cmd.rs +0 -402
- package/temp/rtk/src/runner.rs +0 -271
- package/temp/rtk/src/summary.rs +0 -297
- package/temp/rtk/src/tee.rs +0 -405
- package/temp/rtk/src/telemetry.rs +0 -248
- package/temp/rtk/src/toml_filter.rs +0 -1655
- package/temp/rtk/src/tracking.rs +0 -1416
- package/temp/rtk/src/tree.rs +0 -209
- package/temp/rtk/src/tsc_cmd.rs +0 -259
- package/temp/rtk/src/utils.rs +0 -432
- package/temp/rtk/src/verify_cmd.rs +0 -47
- package/temp/rtk/src/vitest_cmd.rs +0 -385
- package/temp/rtk/src/wc_cmd.rs +0 -401
- package/temp/rtk/src/wget_cmd.rs +0 -260
- package/temp/rtk/tests/fixtures/dotnet/build_failed.txt +0 -11
- package/temp/rtk/tests/fixtures/dotnet/format_changes.json +0 -31
- package/temp/rtk/tests/fixtures/dotnet/format_empty.json +0 -1
- package/temp/rtk/tests/fixtures/dotnet/format_success.json +0 -12
- package/temp/rtk/tests/fixtures/dotnet/test_failed.txt +0 -18
package/temp/rtk/src/go_cmd.rs
DELETED
|
@@ -1,592 +0,0 @@
|
|
|
1
|
-
use crate::tracking;
|
|
2
|
-
use crate::utils::truncate;
|
|
3
|
-
use anyhow::{Context, Result};
|
|
4
|
-
use serde::Deserialize;
|
|
5
|
-
use std::collections::HashMap;
|
|
6
|
-
use std::ffi::OsString;
|
|
7
|
-
use std::process::Command;
|
|
8
|
-
|
|
9
|
-
#[derive(Debug, Deserialize)]
|
|
10
|
-
#[allow(dead_code)]
|
|
11
|
-
struct GoTestEvent {
|
|
12
|
-
#[serde(rename = "Time")]
|
|
13
|
-
time: Option<String>,
|
|
14
|
-
#[serde(rename = "Action")]
|
|
15
|
-
action: String,
|
|
16
|
-
#[serde(rename = "Package")]
|
|
17
|
-
package: Option<String>,
|
|
18
|
-
#[serde(rename = "Test")]
|
|
19
|
-
test: Option<String>,
|
|
20
|
-
#[serde(rename = "Output")]
|
|
21
|
-
output: Option<String>,
|
|
22
|
-
#[serde(rename = "Elapsed")]
|
|
23
|
-
elapsed: Option<f64>,
|
|
24
|
-
#[serde(rename = "ImportPath")]
|
|
25
|
-
import_path: Option<String>,
|
|
26
|
-
#[serde(rename = "FailedBuild")]
|
|
27
|
-
failed_build: Option<String>,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
#[derive(Debug, Default)]
|
|
31
|
-
struct PackageResult {
|
|
32
|
-
pass: usize,
|
|
33
|
-
fail: usize,
|
|
34
|
-
skip: usize,
|
|
35
|
-
build_failed: bool,
|
|
36
|
-
build_errors: Vec<String>,
|
|
37
|
-
failed_tests: Vec<(String, Vec<String>)>, // (test_name, output_lines)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pub fn run_test(args: &[String], verbose: u8) -> Result<()> {
|
|
41
|
-
let timer = tracking::TimedExecution::start();
|
|
42
|
-
|
|
43
|
-
let mut cmd = Command::new("go");
|
|
44
|
-
cmd.arg("test");
|
|
45
|
-
|
|
46
|
-
// Force JSON output if not already specified
|
|
47
|
-
if !args.iter().any(|a| a == "-json") {
|
|
48
|
-
cmd.arg("-json");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for arg in args {
|
|
52
|
-
cmd.arg(arg);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if verbose > 0 {
|
|
56
|
-
eprintln!("Running: go test -json {}", args.join(" "));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let output = cmd
|
|
60
|
-
.output()
|
|
61
|
-
.context("Failed to run go test. Is Go installed?")?;
|
|
62
|
-
|
|
63
|
-
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
64
|
-
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
65
|
-
let raw = format!("{}\n{}", stdout, stderr);
|
|
66
|
-
|
|
67
|
-
let exit_code = output
|
|
68
|
-
.status
|
|
69
|
-
.code()
|
|
70
|
-
.unwrap_or(if output.status.success() { 0 } else { 1 });
|
|
71
|
-
let filtered = filter_go_test_json(&stdout);
|
|
72
|
-
|
|
73
|
-
if let Some(hint) = crate::tee::tee_and_hint(&raw, "go_test", exit_code) {
|
|
74
|
-
println!("{}\n{}", filtered, hint);
|
|
75
|
-
} else {
|
|
76
|
-
println!("{}", filtered);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Include stderr if present (build errors, etc.)
|
|
80
|
-
if !stderr.trim().is_empty() {
|
|
81
|
-
eprintln!("{}", stderr.trim());
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
timer.track(
|
|
85
|
-
&format!("go test {}", args.join(" ")),
|
|
86
|
-
&format!("rtk go test {}", args.join(" ")),
|
|
87
|
-
&raw,
|
|
88
|
-
&filtered,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// Preserve exit code for CI/CD
|
|
92
|
-
if !output.status.success() {
|
|
93
|
-
std::process::exit(exit_code);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
Ok(())
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
pub fn run_build(args: &[String], verbose: u8) -> Result<()> {
|
|
100
|
-
let timer = tracking::TimedExecution::start();
|
|
101
|
-
|
|
102
|
-
let mut cmd = Command::new("go");
|
|
103
|
-
cmd.arg("build");
|
|
104
|
-
|
|
105
|
-
for arg in args {
|
|
106
|
-
cmd.arg(arg);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if verbose > 0 {
|
|
110
|
-
eprintln!("Running: go build {}", args.join(" "));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
let output = cmd
|
|
114
|
-
.output()
|
|
115
|
-
.context("Failed to run go build. Is Go installed?")?;
|
|
116
|
-
|
|
117
|
-
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
118
|
-
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
119
|
-
let raw = format!("{}\n{}", stdout, stderr);
|
|
120
|
-
|
|
121
|
-
let exit_code = output
|
|
122
|
-
.status
|
|
123
|
-
.code()
|
|
124
|
-
.unwrap_or(if output.status.success() { 0 } else { 1 });
|
|
125
|
-
let filtered = filter_go_build(&raw);
|
|
126
|
-
|
|
127
|
-
if let Some(hint) = crate::tee::tee_and_hint(&raw, "go_build", exit_code) {
|
|
128
|
-
if !filtered.is_empty() {
|
|
129
|
-
println!("{}\n{}", filtered, hint);
|
|
130
|
-
} else {
|
|
131
|
-
println!("{}", hint);
|
|
132
|
-
}
|
|
133
|
-
} else if !filtered.is_empty() {
|
|
134
|
-
println!("{}", filtered);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
timer.track(
|
|
138
|
-
&format!("go build {}", args.join(" ")),
|
|
139
|
-
&format!("rtk go build {}", args.join(" ")),
|
|
140
|
-
&raw,
|
|
141
|
-
&filtered,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
// Preserve exit code for CI/CD
|
|
145
|
-
if !output.status.success() {
|
|
146
|
-
std::process::exit(exit_code);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
Ok(())
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
pub fn run_vet(args: &[String], verbose: u8) -> Result<()> {
|
|
153
|
-
let timer = tracking::TimedExecution::start();
|
|
154
|
-
|
|
155
|
-
let mut cmd = Command::new("go");
|
|
156
|
-
cmd.arg("vet");
|
|
157
|
-
|
|
158
|
-
for arg in args {
|
|
159
|
-
cmd.arg(arg);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if verbose > 0 {
|
|
163
|
-
eprintln!("Running: go vet {}", args.join(" "));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
let output = cmd
|
|
167
|
-
.output()
|
|
168
|
-
.context("Failed to run go vet. Is Go installed?")?;
|
|
169
|
-
|
|
170
|
-
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
171
|
-
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
172
|
-
let raw = format!("{}\n{}", stdout, stderr);
|
|
173
|
-
|
|
174
|
-
let exit_code = output
|
|
175
|
-
.status
|
|
176
|
-
.code()
|
|
177
|
-
.unwrap_or(if output.status.success() { 0 } else { 1 });
|
|
178
|
-
let filtered = filter_go_vet(&raw);
|
|
179
|
-
|
|
180
|
-
if let Some(hint) = crate::tee::tee_and_hint(&raw, "go_vet", exit_code) {
|
|
181
|
-
if !filtered.is_empty() {
|
|
182
|
-
println!("{}\n{}", filtered, hint);
|
|
183
|
-
} else {
|
|
184
|
-
println!("{}", hint);
|
|
185
|
-
}
|
|
186
|
-
} else if !filtered.is_empty() {
|
|
187
|
-
println!("{}", filtered);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
timer.track(
|
|
191
|
-
&format!("go vet {}", args.join(" ")),
|
|
192
|
-
&format!("rtk go vet {}", args.join(" ")),
|
|
193
|
-
&raw,
|
|
194
|
-
&filtered,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
// Preserve exit code for CI/CD
|
|
198
|
-
if !output.status.success() {
|
|
199
|
-
std::process::exit(exit_code);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
Ok(())
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
pub fn run_other(args: &[OsString], verbose: u8) -> Result<()> {
|
|
206
|
-
if args.is_empty() {
|
|
207
|
-
anyhow::bail!("go: no subcommand specified");
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
let timer = tracking::TimedExecution::start();
|
|
211
|
-
|
|
212
|
-
let subcommand = args[0].to_string_lossy();
|
|
213
|
-
let mut cmd = Command::new("go");
|
|
214
|
-
cmd.arg(&*subcommand);
|
|
215
|
-
|
|
216
|
-
for arg in &args[1..] {
|
|
217
|
-
cmd.arg(arg);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if verbose > 0 {
|
|
221
|
-
eprintln!("Running: go {} ...", subcommand);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
let output = cmd
|
|
225
|
-
.output()
|
|
226
|
-
.with_context(|| format!("Failed to run go {}", subcommand))?;
|
|
227
|
-
|
|
228
|
-
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
229
|
-
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
230
|
-
let raw = format!("{}\n{}", stdout, stderr);
|
|
231
|
-
|
|
232
|
-
print!("{}", stdout);
|
|
233
|
-
eprint!("{}", stderr);
|
|
234
|
-
|
|
235
|
-
timer.track(
|
|
236
|
-
&format!("go {}", subcommand),
|
|
237
|
-
&format!("rtk go {}", subcommand),
|
|
238
|
-
&raw,
|
|
239
|
-
&raw, // No filtering for unsupported commands
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
// Preserve exit code
|
|
243
|
-
if !output.status.success() {
|
|
244
|
-
std::process::exit(output.status.code().unwrap_or(1));
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
Ok(())
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/// Parse go test -json output (NDJSON format)
|
|
251
|
-
fn filter_go_test_json(output: &str) -> String {
|
|
252
|
-
let mut packages: HashMap<String, PackageResult> = HashMap::new();
|
|
253
|
-
let mut current_test_output: HashMap<(String, String), Vec<String>> = HashMap::new(); // (package, test) -> outputs
|
|
254
|
-
let mut build_output: HashMap<String, Vec<String>> = HashMap::new(); // import_path -> error lines
|
|
255
|
-
|
|
256
|
-
for line in output.lines() {
|
|
257
|
-
let trimmed = line.trim();
|
|
258
|
-
if trimmed.is_empty() {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
let event: GoTestEvent = match serde_json::from_str(trimmed) {
|
|
263
|
-
Ok(e) => e,
|
|
264
|
-
Err(_) => continue, // Skip non-JSON lines
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// Handle build-output/build-fail events (use ImportPath, no Package)
|
|
268
|
-
match event.action.as_str() {
|
|
269
|
-
"build-output" => {
|
|
270
|
-
if let (Some(import_path), Some(output_text)) = (&event.import_path, &event.output)
|
|
271
|
-
{
|
|
272
|
-
let text = output_text.trim_end().to_string();
|
|
273
|
-
if !text.is_empty() {
|
|
274
|
-
build_output
|
|
275
|
-
.entry(import_path.clone())
|
|
276
|
-
.or_default()
|
|
277
|
-
.push(text);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
"build-fail" => {
|
|
283
|
-
// build-fail has ImportPath — we'll handle it when the package-level fail arrives
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
_ => {}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
let package = event.package.unwrap_or_else(|| "unknown".to_string());
|
|
290
|
-
let pkg_result = packages.entry(package.clone()).or_default();
|
|
291
|
-
|
|
292
|
-
match event.action.as_str() {
|
|
293
|
-
"pass" => {
|
|
294
|
-
if event.test.is_some() {
|
|
295
|
-
pkg_result.pass += 1;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
"fail" => {
|
|
299
|
-
if let Some(test) = &event.test {
|
|
300
|
-
// Individual test failure
|
|
301
|
-
pkg_result.fail += 1;
|
|
302
|
-
|
|
303
|
-
// Collect output for failed test
|
|
304
|
-
let key = (package.clone(), test.clone());
|
|
305
|
-
let outputs = current_test_output.remove(&key).unwrap_or_default();
|
|
306
|
-
pkg_result.failed_tests.push((test.clone(), outputs));
|
|
307
|
-
} else if event.failed_build.is_some() {
|
|
308
|
-
// Package-level build failure
|
|
309
|
-
pkg_result.build_failed = true;
|
|
310
|
-
// Collect build errors from the import path
|
|
311
|
-
if let Some(import_path) = &event.failed_build {
|
|
312
|
-
if let Some(errors) = build_output.remove(import_path) {
|
|
313
|
-
pkg_result.build_errors = errors;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
"skip" => {
|
|
319
|
-
if event.test.is_some() {
|
|
320
|
-
pkg_result.skip += 1;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
"output" => {
|
|
324
|
-
// Collect output for current test
|
|
325
|
-
if let (Some(test), Some(output_text)) = (&event.test, &event.output) {
|
|
326
|
-
let key = (package.clone(), test.clone());
|
|
327
|
-
current_test_output
|
|
328
|
-
.entry(key)
|
|
329
|
-
.or_default()
|
|
330
|
-
.push(output_text.trim_end().to_string());
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
_ => {} // run, pause, cont, etc.
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Build summary
|
|
338
|
-
let total_packages = packages.len();
|
|
339
|
-
let total_pass: usize = packages.values().map(|p| p.pass).sum();
|
|
340
|
-
let total_fail: usize = packages.values().map(|p| p.fail).sum();
|
|
341
|
-
let total_skip: usize = packages.values().map(|p| p.skip).sum();
|
|
342
|
-
let total_build_fail: usize = packages.values().filter(|p| p.build_failed).count();
|
|
343
|
-
|
|
344
|
-
let has_failures = total_fail > 0 || total_build_fail > 0;
|
|
345
|
-
|
|
346
|
-
if !has_failures && total_pass == 0 {
|
|
347
|
-
return "Go test: No tests found".to_string();
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if !has_failures {
|
|
351
|
-
return format!(
|
|
352
|
-
"✓ Go test: {} passed in {} packages",
|
|
353
|
-
total_pass, total_packages
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
let mut result = String::new();
|
|
358
|
-
result.push_str(&format!(
|
|
359
|
-
"Go test: {} passed, {} failed",
|
|
360
|
-
total_pass,
|
|
361
|
-
total_fail + total_build_fail
|
|
362
|
-
));
|
|
363
|
-
if total_skip > 0 {
|
|
364
|
-
result.push_str(&format!(", {} skipped", total_skip));
|
|
365
|
-
}
|
|
366
|
-
result.push_str(&format!(" in {} packages\n", total_packages));
|
|
367
|
-
result.push_str("═══════════════════════════════════════\n");
|
|
368
|
-
|
|
369
|
-
// Show build failures first
|
|
370
|
-
for (package, pkg_result) in packages.iter() {
|
|
371
|
-
if !pkg_result.build_failed {
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
result.push_str(&format!(
|
|
376
|
-
"\n📦 {} [build failed]\n",
|
|
377
|
-
compact_package_name(package)
|
|
378
|
-
));
|
|
379
|
-
|
|
380
|
-
for line in &pkg_result.build_errors {
|
|
381
|
-
let trimmed = line.trim();
|
|
382
|
-
// Skip the "# package" header line
|
|
383
|
-
if !trimmed.starts_with('#') && !trimmed.is_empty() {
|
|
384
|
-
result.push_str(&format!(" {}\n", truncate(trimmed, 120)));
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// Show failed tests grouped by package
|
|
390
|
-
for (package, pkg_result) in packages.iter() {
|
|
391
|
-
if pkg_result.fail == 0 {
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
result.push_str(&format!(
|
|
396
|
-
"\n📦 {} ({} passed, {} failed)\n",
|
|
397
|
-
compact_package_name(package),
|
|
398
|
-
pkg_result.pass,
|
|
399
|
-
pkg_result.fail
|
|
400
|
-
));
|
|
401
|
-
|
|
402
|
-
for (test, outputs) in &pkg_result.failed_tests {
|
|
403
|
-
result.push_str(&format!(" ❌ {}\n", test));
|
|
404
|
-
|
|
405
|
-
// Show failure output (limit to key lines)
|
|
406
|
-
let relevant_lines: Vec<&String> = outputs
|
|
407
|
-
.iter()
|
|
408
|
-
.filter(|line| {
|
|
409
|
-
let lower = line.to_lowercase();
|
|
410
|
-
!line.trim().is_empty()
|
|
411
|
-
&& !line.starts_with("=== RUN")
|
|
412
|
-
&& !line.starts_with("--- FAIL")
|
|
413
|
-
&& (lower.contains("error")
|
|
414
|
-
|| lower.contains("expected")
|
|
415
|
-
|| lower.contains("got")
|
|
416
|
-
|| lower.contains("panic")
|
|
417
|
-
|| line.trim().starts_with("at "))
|
|
418
|
-
})
|
|
419
|
-
.take(5)
|
|
420
|
-
.collect();
|
|
421
|
-
|
|
422
|
-
for line in relevant_lines {
|
|
423
|
-
result.push_str(&format!(" {}\n", truncate(line, 100)));
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
result.trim().to_string()
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/// Filter go build output - show only errors
|
|
432
|
-
fn filter_go_build(output: &str) -> String {
|
|
433
|
-
let mut errors: Vec<String> = Vec::new();
|
|
434
|
-
|
|
435
|
-
for line in output.lines() {
|
|
436
|
-
let trimmed = line.trim();
|
|
437
|
-
let lower = trimmed.to_lowercase();
|
|
438
|
-
|
|
439
|
-
// Skip package markers (# package/name lines without errors)
|
|
440
|
-
if trimmed.starts_with('#') && !lower.contains("error") {
|
|
441
|
-
continue;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// Collect error lines (file:line:col format or error keywords)
|
|
445
|
-
if !trimmed.is_empty()
|
|
446
|
-
&& (lower.contains("error")
|
|
447
|
-
|| trimmed.contains(".go:")
|
|
448
|
-
|| lower.contains("undefined")
|
|
449
|
-
|| lower.contains("cannot"))
|
|
450
|
-
{
|
|
451
|
-
errors.push(trimmed.to_string());
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if errors.is_empty() {
|
|
456
|
-
return "✓ Go build: Success".to_string();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
let mut result = String::new();
|
|
460
|
-
result.push_str(&format!("Go build: {} errors\n", errors.len()));
|
|
461
|
-
result.push_str("═══════════════════════════════════════\n");
|
|
462
|
-
|
|
463
|
-
for (i, error) in errors.iter().take(20).enumerate() {
|
|
464
|
-
result.push_str(&format!("{}. {}\n", i + 1, truncate(error, 120)));
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if errors.len() > 20 {
|
|
468
|
-
result.push_str(&format!("\n... +{} more errors\n", errors.len() - 20));
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
result.trim().to_string()
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/// Filter go vet output - show issues
|
|
475
|
-
fn filter_go_vet(output: &str) -> String {
|
|
476
|
-
let mut issues: Vec<String> = Vec::new();
|
|
477
|
-
|
|
478
|
-
for line in output.lines() {
|
|
479
|
-
let trimmed = line.trim();
|
|
480
|
-
|
|
481
|
-
// Collect issue lines (vet reports issues with file:line:col format)
|
|
482
|
-
if !trimmed.is_empty() && !trimmed.starts_with('#') && trimmed.contains(".go:") {
|
|
483
|
-
issues.push(trimmed.to_string());
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if issues.is_empty() {
|
|
488
|
-
return "✓ Go vet: No issues found".to_string();
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
let mut result = String::new();
|
|
492
|
-
result.push_str(&format!("Go vet: {} issues\n", issues.len()));
|
|
493
|
-
result.push_str("═══════════════════════════════════════\n");
|
|
494
|
-
|
|
495
|
-
for (i, issue) in issues.iter().take(20).enumerate() {
|
|
496
|
-
result.push_str(&format!("{}. {}\n", i + 1, truncate(issue, 120)));
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
if issues.len() > 20 {
|
|
500
|
-
result.push_str(&format!("\n... +{} more issues\n", issues.len() - 20));
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
result.trim().to_string()
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/// Compact package name (remove long paths)
|
|
507
|
-
fn compact_package_name(package: &str) -> String {
|
|
508
|
-
// Remove common module prefixes like github.com/user/repo/
|
|
509
|
-
if let Some(pos) = package.rfind('/') {
|
|
510
|
-
package[pos + 1..].to_string()
|
|
511
|
-
} else {
|
|
512
|
-
package.to_string()
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
#[cfg(test)]
|
|
517
|
-
mod tests {
|
|
518
|
-
use super::*;
|
|
519
|
-
|
|
520
|
-
#[test]
|
|
521
|
-
fn test_filter_go_test_all_pass() {
|
|
522
|
-
let output = r#"{"Time":"2024-01-01T10:00:00Z","Action":"run","Package":"example.com/foo","Test":"TestBar"}
|
|
523
|
-
{"Time":"2024-01-01T10:00:01Z","Action":"output","Package":"example.com/foo","Test":"TestBar","Output":"=== RUN TestBar\n"}
|
|
524
|
-
{"Time":"2024-01-01T10:00:02Z","Action":"pass","Package":"example.com/foo","Test":"TestBar","Elapsed":0.5}
|
|
525
|
-
{"Time":"2024-01-01T10:00:02Z","Action":"pass","Package":"example.com/foo","Elapsed":0.5}"#;
|
|
526
|
-
|
|
527
|
-
let result = filter_go_test_json(output);
|
|
528
|
-
assert!(result.contains("✓ Go test"));
|
|
529
|
-
assert!(result.contains("1 passed"));
|
|
530
|
-
assert!(result.contains("1 packages"));
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
#[test]
|
|
534
|
-
fn test_filter_go_test_with_failures() {
|
|
535
|
-
let output = r#"{"Time":"2024-01-01T10:00:00Z","Action":"run","Package":"example.com/foo","Test":"TestFail"}
|
|
536
|
-
{"Time":"2024-01-01T10:00:01Z","Action":"output","Package":"example.com/foo","Test":"TestFail","Output":"=== RUN TestFail\n"}
|
|
537
|
-
{"Time":"2024-01-01T10:00:02Z","Action":"output","Package":"example.com/foo","Test":"TestFail","Output":" Error: expected 5, got 3\n"}
|
|
538
|
-
{"Time":"2024-01-01T10:00:03Z","Action":"fail","Package":"example.com/foo","Test":"TestFail","Elapsed":0.5}
|
|
539
|
-
{"Time":"2024-01-01T10:00:03Z","Action":"fail","Package":"example.com/foo","Elapsed":0.5}"#;
|
|
540
|
-
|
|
541
|
-
let result = filter_go_test_json(output);
|
|
542
|
-
assert!(result.contains("1 failed"));
|
|
543
|
-
assert!(result.contains("TestFail"));
|
|
544
|
-
assert!(result.contains("expected 5, got 3"));
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
#[test]
|
|
548
|
-
fn test_filter_go_build_success() {
|
|
549
|
-
let output = "";
|
|
550
|
-
let result = filter_go_build(output);
|
|
551
|
-
assert!(result.contains("✓ Go build"));
|
|
552
|
-
assert!(result.contains("Success"));
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
#[test]
|
|
556
|
-
fn test_filter_go_build_errors() {
|
|
557
|
-
let output = r#"# example.com/foo
|
|
558
|
-
main.go:10:5: undefined: missingFunc
|
|
559
|
-
main.go:15:2: cannot use x (type int) as type string"#;
|
|
560
|
-
|
|
561
|
-
let result = filter_go_build(output);
|
|
562
|
-
assert!(result.contains("2 errors"));
|
|
563
|
-
assert!(result.contains("undefined: missingFunc"));
|
|
564
|
-
assert!(result.contains("cannot use x"));
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
#[test]
|
|
568
|
-
fn test_filter_go_vet_no_issues() {
|
|
569
|
-
let output = "";
|
|
570
|
-
let result = filter_go_vet(output);
|
|
571
|
-
assert!(result.contains("✓ Go vet"));
|
|
572
|
-
assert!(result.contains("No issues found"));
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
#[test]
|
|
576
|
-
fn test_filter_go_vet_with_issues() {
|
|
577
|
-
let output = r#"main.go:42:2: Printf format %d has arg x of wrong type string
|
|
578
|
-
utils.go:15:5: unreachable code"#;
|
|
579
|
-
|
|
580
|
-
let result = filter_go_vet(output);
|
|
581
|
-
assert!(result.contains("2 issues"));
|
|
582
|
-
assert!(result.contains("Printf format"));
|
|
583
|
-
assert!(result.contains("unreachable code"));
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
#[test]
|
|
587
|
-
fn test_compact_package_name() {
|
|
588
|
-
assert_eq!(compact_package_name("github.com/user/repo/pkg"), "pkg");
|
|
589
|
-
assert_eq!(compact_package_name("example.com/foo"), "foo");
|
|
590
|
-
assert_eq!(compact_package_name("simple"), "simple");
|
|
591
|
-
}
|
|
592
|
-
}
|