work work hard work
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using StellaOps.Scanner.CallGraph;
|
||||
using StellaOps.Scanner.CallGraph.Node;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Scanner.CallGraph.Tests;
|
||||
|
||||
public class BenchmarkIntegrationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("unsafe-eval", true)]
|
||||
[InlineData("guarded-eval", false)]
|
||||
public async Task NodeTraceExtractor_AlignsWithBenchmarkReachability(string caseName, bool expectSinkReachable)
|
||||
{
|
||||
var repoRoot = FindRepoRoot();
|
||||
var caseDir = Path.Combine(repoRoot, "bench", "reachability-benchmark", "cases", "js", caseName);
|
||||
|
||||
var extractor = new NodeCallGraphExtractor();
|
||||
var snapshot = await extractor.ExtractAsync(new CallGraphExtractionRequest(
|
||||
ScanId: $"bench-{caseName}",
|
||||
Language: "node",
|
||||
TargetPath: caseDir));
|
||||
|
||||
var analyzer = new ReachabilityAnalyzer();
|
||||
var result = analyzer.Analyze(snapshot);
|
||||
|
||||
Assert.Equal(expectSinkReachable, result.ReachableSinkIds.Length > 0);
|
||||
}
|
||||
|
||||
private static string FindRepoRoot()
|
||||
{
|
||||
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
while (directory is not null)
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(directory.FullName, "bench", "reachability-benchmark")))
|
||||
{
|
||||
return directory.FullName;
|
||||
}
|
||||
|
||||
directory = directory.Parent;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unable to locate repository root for benchmark integration tests.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user