Skip to content

Commit 5b059cf

Browse files
committed
work
1 parent 0a2a48a commit 5b059cf

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/CodeQLToolkit.Features.Test/Commands/Targets/Actions/ExecuteUnitTestsCommandTarget.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override void Run()
2323
// get a directory to work in
2424
var tmpDirectory = WorkDirectory;
2525

26-
var languageRoot = Path.Combine(Base, Language);
26+
var languageRoot = Path.Combine(Base, Language);
2727

2828
// check if the language root exists
2929
if (!Directory.Exists(languageRoot)){
@@ -41,11 +41,11 @@ public override void Run()
4141
Log<ExecuteUnitTestsCommandTarget>.G().LogInformation($"Found test directory: {dir}");
4242
}
4343

44+
var transformedDirs = dirs.Select(dir => Path.GetRelativePath(Base, dir));
45+
4446
Parallel.For(0, NumThreads,
4547
slice => {
4648

47-
var testPathString = string.Join(" ", dirs);
48-
4949
TestReport report = new TestReport()
5050
{
5151
RunnerOS = RunnerOS,
@@ -56,24 +56,30 @@ public override void Run()
5656
NumSlices = NumThreads
5757
};
5858

59+
var workingDirectory = Path.GetFullPath(Base);
60+
var testPathString = string.Join(" ", transformedDirs);
5961
var outFileReport = Path.Combine(tmpDirectory, report.FileName);
6062

61-
Log<ExecuteUnitTestsCommandTarget>.G().LogInformation($"Running unit tests for slice {slice} to file {outFileReport}...");
63+
Log<ExecuteUnitTestsCommandTarget>.G().LogInformation($"Executing tests in working directory {workingDirectory}.");
64+
Log<ExecuteUnitTestsCommandTarget>.G().LogInformation($"Test Paths: {testPathString}");
65+
Log<ExecuteUnitTestsCommandTarget>.G().LogInformation($"Slice: {slice} of {NumThreads}");
66+
Log<ExecuteUnitTestsCommandTarget>.G().LogInformation($"Report File: {outFileReport}...");
6267

6368
using (Process process = new Process())
6469
{
6570
process.StartInfo.FileName = "codeql";
66-
process.StartInfo.WorkingDirectory = Base;
71+
process.StartInfo.WorkingDirectory = workingDirectory;
6772
process.StartInfo.UseShellExecute = false;
6873
process.StartInfo.RedirectStandardOutput = true;
6974
process.StartInfo.RedirectStandardError = false;
7075
process.StartInfo.Arguments = $"test run --failing-exitcode=122 --slice={slice+1}/{NumThreads} --ram=2048 --format=json --search-path={Language} {testPathString}";
71-
process.StartInfo.FileName = outFileReport;
7276

7377
process.Start();
7478

7579
// needed for STDOUT redirection
76-
process.StandardOutput.ReadToEnd();
80+
var output = process.StandardOutput.ReadToEnd();
81+
82+
File.WriteAllText(outFileReport, output);
7783

7884
process.WaitForExit();
7985

src/CodeQLToolkit.Features.Test/Templates/Test/Actions/run-unit-tests.liquid

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ jobs:
8585
CODEQL_STDLIB_IDENT: ${{matrix.codeql_standard_library_ident}}
8686
RUNNER_TMP: ${{ runner.temp }}
8787
shell: bash
88-
run: |
88+
run: >
8989
{% endraw %}
90-
qlt run test unit-tests \
91-
--num-threads {{ num_threads }} \
92-
--language {{ language }} \
93-
--runner-os $RUNNER_OS \
94-
--cli-version $CODEQL_CLI \
95-
--stdlib-ident $CODEQL_STDLIB_IDENT \
96-
--work-dir $RUNNER_TMP
90+
qlt test execute-unit-tests
91+
--num-threads {{ num_threads }}
92+
--language {{ language }}
93+
--runner-os $RUNNER_OS
94+
--cli-version $CODEQL_CLI
95+
--stdlib-ident $CODEQL_STDLIB_IDENT
96+
--work-dir $RUNNER_TMP
9797
{% raw %}
9898
- name: Upload test results
9999
uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)