次のような PowerShell オブジェクトを作成する必要があります。
release
windows
test1 {testName;passRate}
test2 {testName;passRate}
test3 {testName;passRate}
.
.
Linux
test1 {testName;passRate}
test2 {testName;passRate}
test3 {testName;passRate}
.
.
Trunk
windows
test1 {testName;passRate}
test2 {testName;passRate}
test3 {testName;passRate}
.
.
Linux
test1 {testName;passRate}
test2 {testName;passRate}
test3 {testName;passRate}
.
.
「リリース、トランク、Windows、Linux」静的です。テストは動的です。つまり、テストを追加することになります。
これに対処する方法を知っている人はいますか?
1
既存の入力/データはどのようなものですか?
– マティアス R. ジェッセン
2020 年 9 月 3 日 19:58
現時点ではテストのみです (多くのプロパティがありますが、ここでは名前と合格率のみを使用します)
– ロイ・シドロフスキー
2020 年 9 月 3 日 20:06
メンテナンスが簡単で、PS オブジェクトへの変換が簡単な、ある種のテキスト テンプレートが必要ということですか?
– テオ
2020 年 9 月 3 日 20:07
テスト (合格率が 50% 未満のテストなど) を追加して、それを JSON ファイルに変換できるオブジェクトが必要です。
– ロイ・シドロフスキー
2020 年 9 月 3 日 20:23
次のようなもの: release.windows.add(testname,passrate) または release.windows+=$test ($test は名前と合格率を持つオブジェクトです)
– ロイ・シドロフスキー
2020 年 9 月 3 日 20:25
------------------------
何かを求めていますかこのように?
$WinReleaseTest1 = @{
Name = 'WinTest1'
PassRate = 34
}
$WinReleaseTest2 = @{
Name = 'WinTest2'
PassRate = 56
}
$LinuxReleaseTest1 = @{
Name = 'LinuxTest1'
PassRate = 12
}
$LinuxReleaseTest2 = @{
Name = 'LinuxTest2'
PassRate = 75
}
$WinTrunkTest1 = @{
Name = 'WinTest1'
PassRate = 75
}
$WinTrunkTest2 = @{
Name = 'WinTest2'
PassRate = 6
}
$LinuxTrunkTest1 = @{
Name = 'LinuxTest1'
PassRate = 64
}
$LinuxTrunkTest2 = @{
Name = 'LinuxTest2'
PassRate = 32
}
$AllWinReleaseTests = Get-Variable -Name WinReleaseTest* -ValueOnly
$AllLinuxReleaseTests = Get-Variable -Name LinuxReleaseTest* -ValueOnly
$AllWinTrunkTests = Get-Variable -Name WinTrunkTest* -ValueOnly
$AllLinuxTrunkTests = Get-Variable -Name LinuxTrunkTest* -ValueOnly
$TestSummary = [PSCustomObject]@{
Release = @{
Windows = @{
}
Linux = @{
}
}
Trunk = @{
Windows = @{
}
Linux = @{
}
}
}
foreach ($Test in $AllLinuxReleaseTests) {
$TestSummary.Release.Linux.Add($Test.Name,$Test.PassRate)
}
foreach ($Test in $AllWinReleaseTests) {
$TestSummary.Release.Windows.Add($Test.Name,$Test.PassRate)
}
foreach ($Test in $AllLinuxTrunkTests) {
$TestSummary.Trunk.Linux.Add($Test.Name,$Test.PassRate)
}
foreach ($Test in $AllWinTrunkTests) {
$TestSummary.Trunk.Windows.Add($Test.Name,$Test.PassRate)
}
$TestSummary | ConvertTo-Json
出力:
{
"Release": {
"Windows": {
"WinTest2": 56,
"WinTest1": 34
},
"Linux": {
"LinuxTest1": 12,
"LinuxTest2": 75
}
},
"Trunk": {
"Windows": {
"WinTest2": 6,
"WinTest1": 75
},
"Linux": {
"LinuxTest1": 64,
"LinuxTest2": 32
}
}
}