mirror of
https://github.com/jhuebert/MeshCore.git
synced 2026-12-02 02:18:36 +00:00
fix: keep extends option lines out of the build target list
`pio project config` prints one line per option, so an env that extends another emits `extends = env:<base>` as well as its section header. Matching `env:` anywhere on the line therefore returned that option line as an environment. Every observer target in observer_targets.ini extends a repeater env, so `build.sh list` reported 190 repeater targets instead of 173 — 17 of them named "extends = <base>_repeater". `build-repeater-firmwares` and the local release builder then fed those phantoms to `pio run -e` (the release builder built them one per bogus "platform", serially, and failed). Only the column-0 section headers are environments: anchor the match.
This commit is contained in:
1 parent
c1f67c042e
commit
252ef2e1d1
2 files changed
+40
-1
No files matched your search
@@ -56,7 +56,7 @@ EOF
|
||||
|
||||
# get a list of pio env names that start with "env:"
|
||||
get_pio_envs() {
|
||||
pio project config | grep 'env:' | sed 's/env://'
|
||||
pio project config | grep '^env:' | sed 's/env://'
|
||||
}
|
||||
|
||||
# Catch cries for help before doing anything else.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
class BuildShEnvListTest(unittest.TestCase):
|
||||
def test_list_excludes_extends_option_lines(self):
|
||||
script = Path(__file__).resolve().parents[2] / "build.sh"
|
||||
with tempfile.TemporaryDirectory(prefix="meshcore-build-") as directory:
|
||||
# `pio project config` prints one option line per setting, so an env
|
||||
# that extends another also yields a line holding "env:<base>" — which
|
||||
# is not an environment, however much it looks like one.
|
||||
Path(directory, "pio").write_text(
|
||||
"#!/bin/sh\n"
|
||||
"cat <<'EOF'\n"
|
||||
"env:Heltec_v3_repeater\n"
|
||||
"----------------------\n"
|
||||
"build_flags = -D ESP32_PLATFORM\n"
|
||||
"\n"
|
||||
"env:Heltec_v3_repeater_observer\n"
|
||||
"-------------------------------\n"
|
||||
"extends = env:Heltec_v3_repeater\n"
|
||||
"build_flags = -D ESP32_PLATFORM\n"
|
||||
"EOF\n"
|
||||
)
|
||||
os.chmod(Path(directory, "pio"), 0o755)
|
||||
result = subprocess.run(
|
||||
["bash", str(script), "list"],
|
||||
env={**os.environ, "PATH": directory + os.pathsep + os.environ["PATH"]},
|
||||
check=True, capture_output=True, text=True,
|
||||
)
|
||||
self.assertEqual(result.stdout.splitlines(),
|
||||
["Heltec_v3_repeater", "Heltec_v3_repeater_observer"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user