Skip to content

Commit a779a40

Browse files
committed
apps run test
1 parent e2387d6 commit a779a40

24 files changed

+3087
-233
lines changed

cake/ApaxCmd.cs

Lines changed: 189 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Diagnostics;
1212
using System.IO;
1313
using System.Linq;
14+
using System.Text;
1415
using Cake.Common.IO;
1516
using Cake.Common.Tools.ILMerge;
1617
using Cake.Core.Diagnostics;
@@ -41,7 +42,144 @@ public static void ApaxInstall(this BuildContext context, IEnumerable<string> fo
4142
}
4243
}
4344

44-
public static void ApaxClean(this BuildContext context, (string folder, string name, bool pack) lib)
45+
public static void ApaxInstall(this BuildContext context, string folder)
46+
{
47+
var apaxArguments = "install";
48+
49+
context.Log.Information($"apax {apaxArguments} started in '{folder}'");
50+
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
51+
{
52+
Arguments = apaxArguments,
53+
WorkingDirectory = folder,
54+
RedirectStandardOutput = false,
55+
RedirectStandardError = false,
56+
Silent = false
57+
}).WaitForExit();
58+
context.Log.Information($"apax {apaxArguments} completed successfully in '{folder}'");
59+
}
60+
public static void ApaxPlcSim(this BuildContext context, string folder)
61+
{
62+
var apaxArguments = "plcsim";
63+
64+
context.Log.Information($"apax {apaxArguments} started in '{folder}'");
65+
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
66+
{
67+
Arguments = apaxArguments,
68+
WorkingDirectory = folder,
69+
RedirectStandardOutput = false,
70+
RedirectStandardError = false,
71+
Silent = false
72+
}).WaitForExit();
73+
context.Log.Information($"apax {apaxArguments} completed successfully in '{folder}'");
74+
}
75+
public static string ApaxHwu(this BuildContext context, string folder, ref bool summaryResult)
76+
{
77+
string retVal = ",NOK";
78+
var apaxArguments = "hwu";
79+
80+
context.Log.Information($"apax {apaxArguments} started in '{folder}'");
81+
82+
var processSettings = new ProcessSettings()
83+
{
84+
Arguments = apaxArguments,
85+
WorkingDirectory = folder,
86+
RedirectStandardOutput = true,
87+
RedirectStandardError = true,
88+
Silent = false
89+
};
90+
91+
using (var process = context.ProcessRunner.Start(Helpers.GetApaxCommand(), processSettings))
92+
{
93+
if (process == null)
94+
{
95+
summaryResult = false;
96+
throw new Exception("Failed to start the process.");
97+
}
98+
99+
process.WaitForExit();
100+
101+
var standardOutput = process.GetStandardOutput();
102+
var standardError = process.GetStandardError();
103+
104+
105+
// Check the exit code and handle result
106+
if (process.GetExitCode() == 0)
107+
{
108+
foreach (string line in standardOutput)
109+
{
110+
context.Log.Information(line);
111+
}
112+
context.Log.Information($"apax {apaxArguments} completed successfully in '{folder}'");
113+
retVal = ",OK";
114+
}
115+
else
116+
{
117+
summaryResult = false;
118+
foreach (string line in standardError)
119+
{
120+
context.Log.Error(line);
121+
}
122+
context.Log.Error($"apax {apaxArguments} failed with exit code: {process.GetExitCode()} in '{folder}'");
123+
context.Log.Error($"Error Output: {standardError}");
124+
}
125+
return retVal;
126+
}
127+
}
128+
public static string ApaxSwfd(this BuildContext context, string folder, ref bool summaryResult)
129+
{
130+
string retVal = ",NOK";
131+
var apaxArguments = "swfd";
132+
133+
context.Log.Information($"apax {apaxArguments} started in '{folder}'");
134+
135+
var processSettings = new ProcessSettings()
136+
{
137+
Arguments = apaxArguments,
138+
WorkingDirectory = folder,
139+
RedirectStandardOutput = true,
140+
RedirectStandardError = true,
141+
Silent = false
142+
};
143+
144+
using (var process = context.ProcessRunner.Start(Helpers.GetApaxCommand(), processSettings))
145+
{
146+
if (process == null)
147+
{
148+
summaryResult = false;
149+
throw new Exception("Failed to start the process.");
150+
}
151+
152+
process.WaitForExit();
153+
154+
var standardOutput = process.GetStandardOutput();
155+
var standardError = process.GetStandardError();
156+
157+
158+
// Check the exit code and handle result
159+
if (process.GetExitCode() == 0)
160+
{
161+
foreach (string line in standardOutput)
162+
{
163+
context.Log.Information(line);
164+
}
165+
context.Log.Information($"apax {apaxArguments} completed successfully in '{folder}'");
166+
retVal = ",OK";
167+
}
168+
else
169+
{
170+
summaryResult = false;
171+
foreach (string line in standardError)
172+
{
173+
context.Log.Error(line);
174+
}
175+
context.Log.Error($"apax {apaxArguments} failed with exit code: {process.GetExitCode()} in '{folder}'");
176+
context.Log.Error($"Error Output: {standardError}");
177+
}
178+
return retVal;
179+
}
180+
}
181+
182+
public static void ApaxClean(this BuildContext context, (string folder, string name, bool pack, bool app_run) lib)
45183
{
46184
foreach (var folder in context.GetAxFolders(lib))
47185
{
@@ -85,7 +223,7 @@ public static void ApaxBuild(this BuildContext context, IEnumerable<string> fold
85223
}
86224
}
87225

88-
public static void ApaxUpdate(this BuildContext context, (string folder, string name, bool pack) lib)
226+
public static void ApaxUpdate(this BuildContext context, (string folder, string name, bool pack, bool app_run) lib)
89227
{
90228
foreach (var folder in context.GetAxFolders(lib))
91229
{
@@ -110,7 +248,7 @@ public static void ApaxUpdate(this BuildContext context, (string folder, string
110248
}
111249
}
112250

113-
public static void ApaxPack(this BuildContext context, (string folder, string name, bool pack) lib)
251+
public static void ApaxPack(this BuildContext context, (string folder, string name, bool pack, bool app_run) lib)
114252
{
115253

116254
System.Console.WriteLine(context.ApaxSignKey);
@@ -128,7 +266,7 @@ public static void ApaxPack(this BuildContext context, (string folder, string na
128266
}
129267

130268

131-
public static void ApaxTest(this BuildContext context, (string folder, string name, bool pack) lib)
269+
public static void ApaxTest(this BuildContext context, (string folder, string name, bool pack, bool app_run) lib)
132270
{
133271
foreach (var folder in context.GetAxFolders(lib))
134272
{
@@ -160,7 +298,7 @@ public static void ApaxTest(this BuildContext context, (string folder, string na
160298
}
161299
}
162300

163-
public static void ApaxTestLibrary(this BuildContext context, (string folder, string name, bool pack) lib)
301+
public static void ApaxTestLibrary(this BuildContext context, (string folder, string name, bool pack, bool app_run) lib)
164302
{
165303
foreach (var folder in context.GetLibraryAxFolders(lib))
166304
{
@@ -202,22 +340,22 @@ public static void ApaxTestLibrary(this BuildContext context, (string folder, st
202340
}
203341
}
204342

205-
public static void ApaxIxc(this BuildContext context, IEnumerable<string> folders)
206-
{
207-
foreach (var folder in folders)
208-
{
209-
context.ProcessRunner.Start(Helpers.GetDotNetCommand(), new ProcessSettings()
210-
{
211-
Arguments = "ixc",
212-
WorkingDirectory = folder,
213-
RedirectStandardOutput = false,
214-
RedirectStandardError = false,
215-
Silent = false
216-
}).WaitForExit();
217-
}
218-
}
219-
220-
public static void ApaxCopyArtifacts(this BuildContext context, (string folder, string name, bool pack) lib)
343+
//public static void ApaxIxc(this BuildContext context, IEnumerable<string> folders)
344+
//{
345+
// foreach (var folder in folders)
346+
// {
347+
// context.ProcessRunner.Start(Helpers.GetDotNetCommand(), new ProcessSettings()
348+
// {
349+
// Arguments = "ixc",
350+
// WorkingDirectory = folder,
351+
// RedirectStandardOutput = false,
352+
// RedirectStandardError = false,
353+
// Silent = false
354+
// }).WaitForExit();
355+
// }
356+
//}
357+
358+
public static void ApaxCopyArtifacts(this BuildContext context, (string folder, string name, bool pack, bool app_run) lib)
221359
{
222360
if (lib.pack)
223361
{
@@ -388,4 +526,34 @@ public static void ApaxCatalogInstall(this BuildContext context, string yamlFile
388526
}
389527
}
390528
}
529+
530+
//public static void RunPowershellScript(this BuildContext context, string scriptPath, string arguments)
531+
//{
532+
// string workDir = Path.GetFullPath(Path.Combine(scriptPath, ".."));
533+
// context.Log.Information($"Powershell script {scriptPath} with arguments '{arguments}' started");
534+
// context.ProcessRunner.Start("powershell.exe", new ProcessSettings()
535+
// {
536+
// Arguments = $"-NoProfile -ExecutionPolicy Bypass -File \"{scriptPath}\" {arguments}",
537+
// WorkingDirectory = workDir,
538+
// RedirectStandardOutput = false,
539+
// RedirectStandardError = false,
540+
// Silent = false
541+
// }).WaitForExit();
542+
// context.Log.Information($"Powershell script {scriptPath} with arguments '{arguments}' finished");
543+
//}
544+
545+
//public static void DotnetClean(this BuildContext context, string slnFilePath, string arguments)
546+
//{
547+
// string workDir = Path.GetFullPath(Path.Combine(slnFilePath, ".."));
548+
// context.Log.Information($"Dotne clean command started with solution: {slnFilePath}");
549+
// context.ProcessRunner.Start(Helpers.GetDotNetCommand(), new ProcessSettings()
550+
// {
551+
// Arguments = arguments,
552+
// WorkingDirectory = workDir,
553+
// RedirectStandardOutput = false,
554+
// RedirectStandardError = false,
555+
// Silent = false
556+
// }).WaitForExit();
557+
// context.Log.Information($"Dotne clean command finished with solution: {slnFilePath}");
558+
//}
391559
}

0 commit comments

Comments
 (0)