Skip to content

Commit 4fcb22d

Browse files
authored
Fix trimmed publish test restore coupling (#3573) (#3638)
1 parent b1e8bf4 commit 4fcb22d

4 files changed

Lines changed: 44 additions & 11 deletions

File tree

TESTING_GUIDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ The test project mirrors the production areas closely.
5151
- `SymbolExtractorTests.Extract_CSharp_InstallScriptFixture_CompletesWithinPracticalBudget`
5252
is a coarse runaway guard for the real `InstallScriptTests.cs` C# extraction fixture. Its wall-clock budget is intentionally broader than a benchmark so slower or noisy CI hosts do not fail the suite for ordinary variance.
5353
- `IndexCommandRunnerTests.RunBackfillFold_PublishedTrimmedBinary_SerializesSuccessAndErrorJson`
54-
publishes a trimmed RID-specific CLI and runs whichever entry point the SDK emits (`cdidx.dll` through `dotnet` or the native `cdidx`/`cdidx.exe` apphost). It is reported as skipped on macOS arm64 while SDK/ILLink can crash before exercising `cdidx` (#2586). Do not assume every SDK/runtime pair writes a `cdidx.dll` into self-contained publish output.
54+
publishes a trimmed RID-specific CLI and runs whichever entry point the SDK emits (`cdidx.dll` through `dotnet` or the native `cdidx`/`cdidx.exe` apphost). Its publish smoke disables NuGet vulnerability auditing because package advisory validation is covered by the normal build/test workflow's package vulnerability check, not by this runtime serialization test. It is reported as skipped on macOS arm64 while SDK/ILLink can crash before exercising `cdidx` (#2586). Do not assume every SDK/runtime pair writes a `cdidx.dll` into self-contained publish output.
5555
- `QueryCommandRunnerTests.RunPublishedTrimmedCli_SerializesQueryJsonAndErrorJson`
56-
uses the same trimmed RID-specific publish path to verify query JSON success and error payloads. If `dotnet publish` reaches an SDK/ILLink tool that requires an unavailable `Microsoft.NETCore.App` runtime, the test is reported as skipped with that missing-runtime diagnostic instead of failing before it can exercise `cdidx` (#3571).
56+
uses the trimmed RID-specific publish path for query JSON coverage, writes publish-specific lock files under the test's temporary intermediate directory, disables NuGet vulnerability auditing for the publish smoke, and runs whichever `cdidx` entry point the SDK emits so the test does not depend on source-tree lock-file mutation, advisory-feed availability, or a DLL-only publish layout. If `dotnet publish` reaches an SDK/ILLink tool that requires an unavailable `Microsoft.NETCore.App` runtime, the test is reported as skipped with that missing-runtime diagnostic instead of failing before it can exercise `cdidx` (#3571). It is also reported as skipped on macOS arm64 because the SDK/ILLink crash happens before the test reaches `cdidx` (#2586).
5757
- `QueryCommandRunnerTests.RunPublishedTrimmedCli_SearchSupportsCSharpRazorAliases`
5858
uses the same trimmed RID-specific publish path to verify C# Razor language aliases. It is also reported as skipped on macOS arm64 because the SDK/ILLink crash happens before the test reaches `cdidx`.
5959
- `McpServerTests.cs`
@@ -259,9 +259,9 @@ dotnet test --filter "FullyQualifiedName~GitHelperTests"
259259
- `SymbolExtractorTests.Extract_CSharp_InstallScriptFixture_CompletesWithinPracticalBudget`
260260
は実ファイル `InstallScriptTests.cs` を C# 抽出に通す coarse な runaway guard です。wall-clock の予算は benchmark より意図的に広く取り、遅い / 混雑した CI host で通常の揺れだけにより suite が失敗しないようにしています。
261261
- `IndexCommandRunnerTests.RunBackfillFold_PublishedTrimmedBinary_SerializesSuccessAndErrorJson`
262-
は trimmed な RID 固有 CLI を publish し、SDK が生成した entry point(`dotnet` 経由の `cdidx.dll`、または native の `cdidx`/`cdidx.exe` apphost)を実行します。macOS arm64 では SDK/ILLink が `cdidx` に到達する前にクラッシュし得るため、このテストは skipped として報告されます(#2586)。self-contained publish output に常に `cdidx.dll` が出るとは仮定しないでください。
262+
は trimmed な RID 固有 CLI を publish し、SDK が生成した entry point(`dotnet` 経由の `cdidx.dll`、または native の `cdidx`/`cdidx.exe` apphost)を実行します。この publish smoke は NuGet 脆弱性監査を無効化します。package advisory の検証は通常の build/test workflow の package vulnerability check が担い、この runtime serialization テストの責務ではないためです。macOS arm64 では SDK/ILLink が `cdidx` に到達する前にクラッシュし得るため、このテストは skipped として報告されます(#2586)。self-contained publish output に常に `cdidx.dll` が出るとは仮定しないでください。
263263
- `QueryCommandRunnerTests.RunPublishedTrimmedCli_SerializesQueryJsonAndErrorJson`
264-
は同じ trimmed RID 固有 publish 経路で query JSON の成功 payload と error payload を検証します。`dotnet publish` が、利用できない `Microsoft.NETCore.App` runtime を必要とする SDK/ILLink tool に到達した場合は、`cdidx` を実行する前に失敗させるのではなく、その missing-runtime diagnostic を付けて skipped として報告します(#3571)。
264+
は query JSON coverage のために trimmed RID 固有 publish 経路を使い、publish 専用の lock file をテストの一時 intermediate directory 配下に書き、publish smoke の NuGet 脆弱性監査を無効化し、SDK が生成した `cdidx` entry point を実行します。source tree の lock file 変更、advisory feed の可用性、DLL 固定の publish layout には依存しません。`dotnet publish` が、利用できない `Microsoft.NETCore.App` runtime を必要とする SDK/ILLink tool に到達した場合は、`cdidx` を実行する前に失敗させるのではなく、その missing-runtime diagnostic を付けて skipped として報告します(#3571)。このテストも macOS arm64 では、`cdidx` に到達する前に SDK/ILLink がクラッシュし得るため skipped として報告されます(#2586)。
265265
- `QueryCommandRunnerTests.RunPublishedTrimmedCli_SearchSupportsCSharpRazorAliases`
266266
は同じ trimmed RID 固有 publish 経路で C# Razor の言語 alias を検証します。このテストも macOS arm64 では、`cdidx` に到達する前に SDK/ILLink がクラッシュし得るため skipped として報告されます。
267267
- `McpServerTests.cs`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 3573
5+
affected:
6+
- tests/CodeIndex.Tests/IndexCommandRunnerTests.cs
7+
- tests/CodeIndex.Tests/QueryCommandRunnerTests.cs
8+
- TESTING_GUIDE.md
9+
---
10+
11+
## English
12+
13+
- **Published trimmed CLI tests no longer assume live restore advisory state (#3573)** — the trimmed-publish smoke tests now use publish-specific lock files, disable NuGet vulnerability auditing for the smoke publish, run whichever `cdidx` entry point the SDK emits, and apply the existing macOS arm64 SDK/ILLink skip to the query JSON smoke test.
14+
15+
## 日本語
16+
17+
- **公開済み trimmed CLI テストが live restore advisory 状態を仮定しないようになりました (#3573)** — trimmed-publish smoke テストは publish 専用の lock file を使い、smoke publish の NuGet 脆弱性監査を無効化し、SDK が生成した `cdidx` entry point を実行し、既存の macOS arm64 SDK/ILLink skip を query JSON smoke test にも適用するようになりました。

tests/CodeIndex.Tests/IndexCommandRunnerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11290,6 +11290,7 @@ private static string PublishTrimmedCli(string outputDir, bool publishSingleFile
1129011290
psi.ArgumentList.Add($"-p:OutputPath={buildOutputDir}");
1129111291
psi.ArgumentList.Add($"-p:IntermediateOutputPath={intermediateDir}");
1129211292
psi.ArgumentList.Add($"-p:NuGetLockFilePath={lockFilePath}");
11293+
psi.ArgumentList.Add("-p:NuGetAudit=false");
1129311294
psi.ArgumentList.Add("-p:UseSharedCompilation=false");
1129411295

1129511296
using var process = System.Diagnostics.Process.Start(psi)

tests/CodeIndex.Tests/QueryCommandRunnerTests.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ public void RunSearchAndSymbols_AcceptPythonPyLangAlias()
13731373

13741374

13751375

1376-
[Fact]
1376+
[SkipOnMacOsArm64Fact]
13771377
public void RunPublishedTrimmedCli_SerializesQueryJsonAndErrorJson()
13781378
{
13791379
var projectRoot = TestProjectHelper.CreateTempProject("cdidx_query_trimmed_publish");
@@ -5334,9 +5334,9 @@ private static (int ExitCode, string StdOut, string StdErr) RunBuiltCli(string[]
53345334
return (process.ExitCode, stdOut, stdErr);
53355335
}
53365336

5337-
private static (int ExitCode, string StdOut, string StdErr) RunPublishedCli(string publishedDll, string workingDirectory, params string[] args)
5337+
private static (int ExitCode, string StdOut, string StdErr) RunPublishedCli(string publishedCli, string workingDirectory, params string[] args)
53385338
{
5339-
var psi = new System.Diagnostics.ProcessStartInfo("dotnet")
5339+
var psi = new System.Diagnostics.ProcessStartInfo
53405340
{
53415341
WorkingDirectory = workingDirectory,
53425342
RedirectStandardInput = true,
@@ -5345,7 +5345,16 @@ private static (int ExitCode, string StdOut, string StdErr) RunPublishedCli(stri
53455345
UseShellExecute = false,
53465346
CreateNoWindow = true,
53475347
};
5348-
psi.ArgumentList.Add(publishedDll);
5348+
if (Path.GetExtension(publishedCli).Equals(".dll", StringComparison.OrdinalIgnoreCase))
5349+
{
5350+
psi.FileName = "dotnet";
5351+
psi.ArgumentList.Add(publishedCli);
5352+
}
5353+
else
5354+
{
5355+
psi.FileName = publishedCli;
5356+
}
5357+
53495358
foreach (var arg in args)
53505359
psi.ArgumentList.Add(arg);
53515360
SanitizeChildCliEnvironment(psi);
@@ -5389,6 +5398,7 @@ private static string PublishTrimmedCli(string outputDir)
53895398
psi.ArgumentList.Add($"-p:OutputPath={buildOutputDir}");
53905399
psi.ArgumentList.Add($"-p:IntermediateOutputPath={intermediateDir}");
53915400
psi.ArgumentList.Add($"-p:NuGetLockFilePath={lockFilePath}");
5401+
psi.ArgumentList.Add("-p:NuGetAudit=false");
53925402
psi.ArgumentList.Add("-p:UseSharedCompilation=false");
53935403

53945404
using var process = System.Diagnostics.Process.Start(psi)
@@ -5405,11 +5415,16 @@ private static string PublishTrimmedCli(string outputDir)
54055415
throw new InvalidOperationException($"dotnet publish failed: {output}");
54065416
}
54075417

5418+
var publishedAppHost = Path.Combine(outputDir, OperatingSystem.IsWindows() ? "cdidx.exe" : "cdidx");
5419+
if (File.Exists(publishedAppHost))
5420+
return publishedAppHost;
5421+
54085422
var publishedDll = Path.Combine(outputDir, "cdidx.dll");
5409-
if (!File.Exists(publishedDll))
5410-
throw new InvalidOperationException($"Published cdidx.dll not found at {publishedDll}");
5423+
if (File.Exists(publishedDll))
5424+
return publishedDll;
54115425

5412-
return publishedDll;
5426+
throw new InvalidOperationException(
5427+
$"Published cdidx entry point not found. Expected {publishedDll} or {publishedAppHost}");
54135428
}
54145429

54155430
private static bool IsMissingDotNetRuntimeFailure(string output)

0 commit comments

Comments
 (0)