ci(tools): Avoiding full rebuilds where not needed to improve performance

This commit is contained in:
Jakub Kocka
2026-03-16 08:53:41 +01:00
parent 02c8a8b99d
commit d860da47c0
4 changed files with 63 additions and 47 deletions
+41 -35
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import json
import os
@@ -50,48 +50,54 @@ class TestWithoutExtensions(TestCase):
class TestExtensions(TestWithoutExtensions):
def test_extension_loading(self):
@classmethod
def setUpClass(cls):
super().setUpClass()
# Create symlink once for all tests in this class
# Handle race conditions with parallel test execution (pytest-xdist)
try:
os.symlink(extension_path, link_path)
os.environ['IDF_EXTRA_ACTIONS_PATH'] = os.path.join(current_dir, 'extra_path')
output = subprocess.check_output([sys.executable, idf_py_path, '--help'], env=os.environ).decode(
'utf-8', 'ignore'
)
except FileExistsError:
# Another worker already created it - that's fine
pass
os.environ['IDF_EXTRA_ACTIONS_PATH'] = os.path.join(current_dir, 'extra_path')
self.assertIn('--test-extension-option', output)
self.assertIn('test_subcommand', output)
self.assertIn('--some-extension-option', output)
self.assertIn('extra_subcommand', output)
finally:
@classmethod
def tearDownClass(cls):
# Clean up symlink after all tests complete
# Use try/except to handle race conditions with parallel execution
try:
os.remove(link_path)
except FileNotFoundError:
# Another worker already removed it - that's fine
pass
super().tearDownClass()
def test_extension_loading(self):
output = subprocess.check_output([sys.executable, idf_py_path, '--help'], env=os.environ).decode(
'utf-8', 'ignore'
)
self.assertIn('--test-extension-option', output)
self.assertIn('test_subcommand', output)
self.assertIn('--some-extension-option', output)
self.assertIn('extra_subcommand', output)
def test_extension_execution(self):
try:
os.symlink(extension_path, link_path)
os.environ['IDF_EXTRA_ACTIONS_PATH'] = ';'.join([os.path.join(current_dir, 'extra_path')])
output = subprocess.check_output(
[sys.executable, idf_py_path, '--some-extension-option=awesome', 'test_subcommand', 'extra_subcommand'],
env=os.environ,
).decode('utf-8', 'ignore')
self.assertIn('!!! From some global callback: awesome', output)
self.assertIn('!!! From some subcommand', output)
self.assertIn('!!! From test global callback: test', output)
self.assertIn('!!! From some subcommand', output)
finally:
os.remove(link_path)
output = subprocess.check_output(
[sys.executable, idf_py_path, '--some-extension-option=awesome', 'test_subcommand', 'extra_subcommand'],
env=os.environ,
).decode('utf-8', 'ignore')
self.assertIn('!!! From some global callback: awesome', output)
self.assertIn('!!! From some subcommand', output)
self.assertIn('!!! From test global callback: test', output)
self.assertIn('!!! From some subcommand', output)
def test_hidden_commands(self):
try:
os.symlink(extension_path, link_path)
os.environ['IDF_EXTRA_ACTIONS_PATH'] = ';'.join([os.path.join(current_dir, 'extra_path')])
output = subprocess.check_output([sys.executable, idf_py_path, '--help'], env=os.environ).decode(
'utf-8', 'ignore'
)
self.assertIn('test_subcommand', output)
self.assertNotIn('hidden_one', output)
finally:
os.remove(link_path)
output = subprocess.check_output([sys.executable, idf_py_path, '--help'], env=os.environ).decode(
'utf-8', 'ignore'
)
self.assertIn('test_subcommand', output)
self.assertNotIn('hidden_one', output)
class TestDependencyManagement(TestWithoutExtensions):