зеркало из https://github.com/github/codeql.git
C#: Avoid process creation indirection in auto-builder
This commit is contained in:
Родитель
3f66b635a4
Коммит
621de2b977
|
@ -544,51 +544,6 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||||
Assert.Equal(2, vcvarsfiles.Length);
|
Assert.Equal(2, vcvarsfiles.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestLinuxBuildlessExtractionSuccess()
|
|
||||||
{
|
|
||||||
actions.RunProcess[@"C:\codeql\csharp/tools/linux64/Semmle.Extraction.CSharp.Standalone"] = 0;
|
|
||||||
actions.FileExists["csharp.log"] = true;
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SCRATCH_DIR"] = "scratch";
|
|
||||||
actions.EnumerateFiles[@"C:\Project"] = "foo.cs\ntest.sln";
|
|
||||||
actions.EnumerateDirectories[@"C:\Project"] = "";
|
|
||||||
|
|
||||||
var autobuilder = CreateAutoBuilder(false, buildless: "true");
|
|
||||||
TestAutobuilderScript(autobuilder, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestLinuxBuildlessExtractionFailed()
|
|
||||||
{
|
|
||||||
actions.RunProcess[@"C:\codeql\csharp/tools/linux64/Semmle.Extraction.CSharp.Standalone"] = 10;
|
|
||||||
actions.FileExists["csharp.log"] = true;
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SCRATCH_DIR"] = "scratch";
|
|
||||||
actions.EnumerateFiles[@"C:\Project"] = "foo.cs\ntest.sln";
|
|
||||||
actions.EnumerateDirectories[@"C:\Project"] = "";
|
|
||||||
|
|
||||||
var autobuilder = CreateAutoBuilder(false, buildless: "true");
|
|
||||||
TestAutobuilderScript(autobuilder, 10, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestLinuxBuildlessExtractionSolution()
|
|
||||||
{
|
|
||||||
actions.RunProcess[@"C:\codeql\csharp/tools/linux64/Semmle.Extraction.CSharp.Standalone"] = 0;
|
|
||||||
actions.FileExists["csharp.log"] = true;
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SCRATCH_DIR"] = "scratch";
|
|
||||||
actions.EnumerateFiles[@"C:\Project"] = "foo.cs\ntest.sln";
|
|
||||||
actions.EnumerateDirectories[@"C:\Project"] = "";
|
|
||||||
|
|
||||||
var autobuilder = CreateAutoBuilder(false, buildless: "true");
|
|
||||||
TestAutobuilderScript(autobuilder, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TestAutobuilderScript(CSharpAutobuilder autobuilder, int expectedOutput, int commandsRun)
|
private void TestAutobuilderScript(CSharpAutobuilder autobuilder, int expectedOutput, int commandsRun)
|
||||||
{
|
{
|
||||||
Assert.Equal(expectedOutput, autobuilder.GetBuildScript().Run(actions, StartCallback, EndCallback));
|
Assert.Equal(expectedOutput, autobuilder.GetBuildScript().Run(actions, StartCallback, EndCallback));
|
||||||
|
@ -677,21 +632,6 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||||
TestAutobuilderScript(autobuilder, 0, 1);
|
TestAutobuilderScript(autobuilder, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestSkipNugetBuildless()
|
|
||||||
{
|
|
||||||
actions.RunProcess[@"C:\codeql\csharp/tools/linux64/Semmle.Extraction.CSharp.Standalone"] = 0;
|
|
||||||
actions.FileExists["csharp.log"] = true;
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR"] = "";
|
|
||||||
actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SCRATCH_DIR"] = "scratch";
|
|
||||||
actions.EnumerateFiles[@"C:\Project"] = "foo.cs\ntest.sln";
|
|
||||||
actions.EnumerateDirectories[@"C:\Project"] = "";
|
|
||||||
|
|
||||||
var autobuilder = CreateAutoBuilder(false, buildless: "true");
|
|
||||||
TestAutobuilderScript(autobuilder, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestDotnetVersionNotInstalled()
|
public void TestDotnetVersionNotInstalled()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
|
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
|
||||||
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
|
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
|
||||||
|
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.Standalone\Semmle.Extraction.CSharp.Standalone.csproj" />
|
||||||
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
|
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
|
||||||
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
|
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -10,17 +10,7 @@ namespace Semmle.Autobuild.CSharp
|
||||||
{
|
{
|
||||||
public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto)
|
public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto)
|
||||||
{
|
{
|
||||||
if (builder.CodeQLExtractorLangRoot is null
|
return BuildScript.Create(_ => Semmle.Extraction.CSharp.Standalone.Program.Main([]));
|
||||||
|| builder.CodeQlPlatform is null)
|
|
||||||
{
|
|
||||||
return BuildScript.Failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
var standalone = builder.Actions.PathCombine(builder.CodeQLExtractorLangRoot, "tools", builder.CodeQlPlatform, "Semmle.Extraction.CSharp.Standalone");
|
|
||||||
var cmd = new CommandBuilder(builder.Actions);
|
|
||||||
cmd.RunCommand(standalone);
|
|
||||||
|
|
||||||
return cmd.Script;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,16 +73,6 @@ namespace Semmle.Autobuild.Shared
|
||||||
/// A logger.
|
/// A logger.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ILogger Logger { get; }
|
ILogger Logger { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Value of CODEQL_EXTRACTOR_<LANG>_ROOT environment variable.
|
|
||||||
/// </summary>
|
|
||||||
string? CodeQLExtractorLangRoot { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Value of CODEQL_PLATFORM environment variable.
|
|
||||||
/// </summary>
|
|
||||||
string? CodeQlPlatform { get; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -197,9 +187,6 @@ namespace Semmle.Autobuild.Shared
|
||||||
return ret ?? new List<IProjectOrSolution>();
|
return ret ?? new List<IProjectOrSolution>();
|
||||||
});
|
});
|
||||||
|
|
||||||
CodeQLExtractorLangRoot = Actions.GetEnvironmentVariable(EnvVars.Root(this.Options.Language));
|
|
||||||
CodeQlPlatform = Actions.GetEnvironmentVariable(EnvVars.Platform);
|
|
||||||
|
|
||||||
TrapDir = RequireEnvironmentVariable(EnvVars.TrapDir(this.Options.Language));
|
TrapDir = RequireEnvironmentVariable(EnvVars.TrapDir(this.Options.Language));
|
||||||
SourceArchiveDir = RequireEnvironmentVariable(EnvVars.SourceArchiveDir(this.Options.Language));
|
SourceArchiveDir = RequireEnvironmentVariable(EnvVars.SourceArchiveDir(this.Options.Language));
|
||||||
DiagnosticsDir = RequireEnvironmentVariable(EnvVars.DiagnosticDir(this.Options.Language));
|
DiagnosticsDir = RequireEnvironmentVariable(EnvVars.DiagnosticDir(this.Options.Language));
|
||||||
|
@ -364,15 +351,5 @@ namespace Semmle.Autobuild.Shared
|
||||||
diagnostics.Dispose();
|
diagnostics.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Value of CODEQL_EXTRACTOR_<LANG>_ROOT environment variable.
|
|
||||||
/// </summary>
|
|
||||||
public string? CodeQLExtractorLangRoot { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Value of CODEQL_PLATFORM environment variable.
|
|
||||||
/// </summary>
|
|
||||||
public string? CodeQlPlatform { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,8 +179,6 @@ function RegisterExtractorPack(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
local windowsMatchers = {
|
local windowsMatchers = {
|
||||||
CreatePatternMatcher({ '^semmle%.extraction%.csharp%.standalone%.exe$' },
|
|
||||||
MatchCompilerName, nil, { trace = false }),
|
|
||||||
DotnetMatcherBuild,
|
DotnetMatcherBuild,
|
||||||
MsBuildMatcher,
|
MsBuildMatcher,
|
||||||
CreatePatternMatcher({ '^csc.*%.exe$' }, MatchCompilerName, extractor, {
|
CreatePatternMatcher({ '^csc.*%.exe$' }, MatchCompilerName, extractor, {
|
||||||
|
@ -222,9 +220,6 @@ function RegisterExtractorPack(id)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
local posixMatchers = {
|
local posixMatchers = {
|
||||||
-- The compiler name is case sensitive on Linux and lower cased on MacOS
|
|
||||||
CreatePatternMatcher({ '^semmle%.extraction%.csharp%.standalone$', '^Semmle%.Extraction%.CSharp%.Standalone$' },
|
|
||||||
MatchCompilerName, nil, { trace = false }),
|
|
||||||
DotnetMatcherBuild,
|
DotnetMatcherBuild,
|
||||||
CreatePatternMatcher({ '^mcs%.exe$', '^csc%.exe$' }, MatchCompilerName,
|
CreatePatternMatcher({ '^mcs%.exe$', '^csc%.exe$' }, MatchCompilerName,
|
||||||
extractor, {
|
extractor, {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче