feat: add witnessed knowledge and wind ambience
This commit is contained in:
+41
-7
@@ -86,6 +86,8 @@ function Test-GdLint {
|
||||
return $false
|
||||
}
|
||||
|
||||
$script:GdToolExitCode = 0
|
||||
|
||||
function Invoke-GdFormat {
|
||||
$args = $args
|
||||
$localTool = "$ROOT/.venv/Scripts/gdformat.exe"
|
||||
@@ -96,6 +98,7 @@ function Invoke-GdFormat {
|
||||
} else {
|
||||
& python -m gdtoolkit.formatter @args 2>&1
|
||||
}
|
||||
$script:GdToolExitCode = $LASTEXITCODE
|
||||
}
|
||||
|
||||
function Invoke-GdLint {
|
||||
@@ -108,11 +111,13 @@ function Invoke-GdLint {
|
||||
} else {
|
||||
& python -m gdtoolkit.linter @args 2>&1
|
||||
}
|
||||
$script:GdToolExitCode = $LASTEXITCODE
|
||||
}
|
||||
|
||||
function Get-ChangedGd {
|
||||
$f = git diff --name-only HEAD -- '*.gd' 2>$null
|
||||
return @($f | Where-Object { $_ -ne '' })
|
||||
$changed = @(git diff --name-only HEAD -- '*.gd' 2>$null)
|
||||
$untracked = @(git ls-files --others --exclude-standard -- '*.gd' 2>$null)
|
||||
return @((@($changed) + @($untracked)) | Where-Object { $_ -ne '' } | Sort-Object -Unique)
|
||||
}
|
||||
|
||||
function To-ResPath($p) {
|
||||
@@ -171,8 +176,10 @@ $hasProjectClasses = (Test-Path $classCache) -and
|
||||
(Select-String -Path $classCache -SimpleMatch '"class": &"SimNPC"' -Quiet)
|
||||
$hasGutClasses = (Test-Path $classCache) -and
|
||||
(Select-String -Path $classCache -SimpleMatch '"class": &"GutTest"' -Quiet)
|
||||
$changedGd = @(Get-ChangedGd)
|
||||
$needsImport = (-not $hasProjectClasses) -or
|
||||
((Test-Path "addons/gut/gut_cmdln.gd") -and (-not $hasGutClasses))
|
||||
((Test-Path "addons/gut/gut_cmdln.gd") -and (-not $hasGutClasses)) -or
|
||||
($changedGd.Count -gt 0)
|
||||
if ($needsImport) {
|
||||
$importArgs = "--headless --path `"$ROOT`" --import"
|
||||
$importOutput, $importExit = Invoke-GodotWithTimeout -ArgumentString $importArgs
|
||||
@@ -200,6 +207,7 @@ if ($importResult -eq "FAIL") {
|
||||
# -- 1. gdformat --------------------------------------------------------------
|
||||
$fmtAvail = Test-GdFormat
|
||||
$fmtResult = "PASS"
|
||||
$fmtFailed = $false
|
||||
Set-Content -Path "$LOG/gdformat.log" -Value "" -Encoding utf8
|
||||
if (-not $fmtAvail) {
|
||||
$fmtResult = "SKIPPED"
|
||||
@@ -215,8 +223,9 @@ if (-not $fmtAvail) {
|
||||
if (-not (Test-Path $f)) { continue }
|
||||
$total++
|
||||
$out = Invoke-GdFormat "--check" $f
|
||||
$formatExit = $script:GdToolExitCode
|
||||
$out | Add-Content -Path "$LOG/gdformat.log" -Encoding utf8
|
||||
if ($LASTEXITCODE -ne 0) { $bad++ }
|
||||
if ($formatExit -ne 0) { $bad++; $fmtFailed = $true }
|
||||
}
|
||||
$msg = "($bad/$total files need formatting)"
|
||||
Add-Content -Path "$LOG/gdformat.log" -Value $msg -Encoding utf8
|
||||
@@ -224,12 +233,15 @@ if (-not $fmtAvail) {
|
||||
} else {
|
||||
$formatArgs = @("--check") + $OWNED_GDSCRIPT_ROOTS
|
||||
$out = Invoke-GdFormat @formatArgs
|
||||
$formatExit = $script:GdToolExitCode
|
||||
$out | Add-Content -Path "$LOG/gdformat.log" -Encoding utf8
|
||||
if ($formatExit -ne 0) { $fmtFailed = $true }
|
||||
}
|
||||
}
|
||||
|
||||
if (Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" -Quiet) {
|
||||
$fmtResult = "FAIL"
|
||||
if ($fmtFailed) { $fmtResult = "FAIL" }
|
||||
$formatDiagnostics = Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" -Quiet
|
||||
if ($formatDiagnostics) {
|
||||
$lines = Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" | Select-Object -ExpandProperty Line
|
||||
foreach ($line in $lines) {
|
||||
$p = ($line -replace '^would reformat ', '').Trim()
|
||||
@@ -237,11 +249,15 @@ if (Select-String -SimpleMatch "would reformat" -Path "$LOG/gdformat.log" -Quiet
|
||||
$ERRORS += "$rp needs formatting"
|
||||
}
|
||||
$FIXES += "Run gdformat to auto-format files"
|
||||
} elseif ($fmtFailed) {
|
||||
$ERRORS += "gdformat: formatter exited non-zero; see $LOG/gdformat.log"
|
||||
$FIXES += "Fix the gdformat error before continuing"
|
||||
}
|
||||
|
||||
# -- 2. gdlint ----------------------------------------------------------------
|
||||
$lintAvail = Test-GdLint
|
||||
$lintResult = "PASS"
|
||||
$lintFailed = $false
|
||||
Set-Content -Path "$LOG/gdlint.log" -Value "" -Encoding utf8
|
||||
if (-not $lintAvail) {
|
||||
$lintResult = "SKIPPED"
|
||||
@@ -255,18 +271,22 @@ if (-not $lintAvail) {
|
||||
foreach ($f in $files) {
|
||||
if (-not (Test-Path $f)) { continue }
|
||||
$out = Invoke-GdLint $f
|
||||
$lintExit = $script:GdToolExitCode
|
||||
$out | Add-Content -Path "$LOG/gdlint.log" -Encoding utf8
|
||||
if ($lintExit -ne 0) { $lintFailed = $true }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$out = Invoke-GdLint @OWNED_GDSCRIPT_ROOTS
|
||||
$lintExit = $script:GdToolExitCode
|
||||
$out | Add-Content -Path "$LOG/gdlint.log" -Encoding utf8
|
||||
if ($lintExit -ne 0) { $lintFailed = $true }
|
||||
}
|
||||
}
|
||||
|
||||
if ($lintFailed) { $lintResult = "FAIL" }
|
||||
$lintLines = Select-String -Pattern '^[^ ]+:\d+:\d+:' -Path "$LOG/gdlint.log" | Select-Object -ExpandProperty Line
|
||||
if ($lintLines) {
|
||||
$lintResult = "FAIL"
|
||||
foreach ($line in $lintLines) {
|
||||
$parts = $line -split ':', 4
|
||||
if ($parts.Count -lt 4) { continue }
|
||||
@@ -280,6 +300,9 @@ if ($lintLines) {
|
||||
$rule = $parts[3]; $fname = Split-Path -Leaf $parts[0]
|
||||
$FIXES += "Fix $rule in $fname"
|
||||
}
|
||||
} elseif ($lintFailed) {
|
||||
$ERRORS += "gdlint: linter exited non-zero; see $LOG/gdlint.log"
|
||||
$FIXES += "Fix the gdlint error before continuing"
|
||||
}
|
||||
|
||||
# -- 3. godot headless check --------------------------------------------------
|
||||
@@ -300,6 +323,12 @@ if ($godotExit -eq $null) {
|
||||
}
|
||||
$FIXES += "Fix Godot parser errors"
|
||||
}
|
||||
$godotLoadError = Select-String -Path "$LOG/godot-check.log" -Pattern 'SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
|
||||
if ($godotLoadError) {
|
||||
$godotResult = "FAIL"
|
||||
$ERRORS += "godot: project check reported a script load or parse error"
|
||||
$FIXES += "Fix Godot parser errors"
|
||||
}
|
||||
|
||||
# -- 4. project scenario tests ------------------------------------------------
|
||||
$scenarioResult = "PASS"
|
||||
@@ -315,6 +344,11 @@ foreach ($test in $scenarioTests) {
|
||||
$ERRORS += "scenario: $($test.Name) failed or timed out"
|
||||
}
|
||||
}
|
||||
$scenarioLoadError = Select-String -Path "$LOG/scenarios.log" -Pattern 'SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
|
||||
if ($scenarioLoadError) {
|
||||
$scenarioResult = "FAIL"
|
||||
$ERRORS += "scenario: Godot reported a script load or parse error"
|
||||
}
|
||||
if ($scenarioResult -eq "FAIL") {
|
||||
$FIXES += "Fix failing project scenario tests"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user