mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Tools: Make idf.py tests independent on extra extensions
This commit is contained in:
@ -15,9 +15,9 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import unittest
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from unittest import TestCase, main
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
@ -36,7 +36,17 @@ extension_path = os.path.join(current_dir, 'test_idf_extensions', 'test_ext')
|
|||||||
link_path = os.path.join(current_dir, '..', 'idf_py_actions', 'test_ext')
|
link_path = os.path.join(current_dir, '..', 'idf_py_actions', 'test_ext')
|
||||||
|
|
||||||
|
|
||||||
class TestExtensions(unittest.TestCase):
|
class TestWithoutExtensions(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.initial_env = dict(os.environ)
|
||||||
|
os.environ['IDF_COMPONENT_MANAGER'] = '0'
|
||||||
|
os.environ['IDF_EXTRA_ACTIONS_PATH'] = ''
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
os.environ = self.initial_env
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtensions(TestWithoutExtensions):
|
||||||
def test_extension_loading(self):
|
def test_extension_loading(self):
|
||||||
try:
|
try:
|
||||||
os.symlink(extension_path, link_path)
|
os.symlink(extension_path, link_path)
|
||||||
@ -78,7 +88,7 @@ class TestExtensions(unittest.TestCase):
|
|||||||
os.remove(link_path)
|
os.remove(link_path)
|
||||||
|
|
||||||
|
|
||||||
class TestDependencyManagement(unittest.TestCase):
|
class TestDependencyManagement(TestWithoutExtensions):
|
||||||
def test_dependencies(self):
|
def test_dependencies(self):
|
||||||
result = idf.init_cli()(
|
result = idf.init_cli()(
|
||||||
args=['--dry-run', 'flash'],
|
args=['--dry-run', 'flash'],
|
||||||
@ -129,7 +139,7 @@ class TestDependencyManagement(unittest.TestCase):
|
|||||||
'WARNING: Command "clean" is found in the list of commands more than once.', capturedOutput.getvalue())
|
'WARNING: Command "clean" is found in the list of commands more than once.', capturedOutput.getvalue())
|
||||||
|
|
||||||
|
|
||||||
class TestVerboseFlag(unittest.TestCase):
|
class TestVerboseFlag(TestWithoutExtensions):
|
||||||
def test_verbose_messages(self):
|
def test_verbose_messages(self):
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
[
|
[
|
||||||
@ -155,7 +165,7 @@ class TestVerboseFlag(unittest.TestCase):
|
|||||||
self.assertNotIn('Verbose mode on', output)
|
self.assertNotIn('Verbose mode on', output)
|
||||||
|
|
||||||
|
|
||||||
class TestGlobalAndSubcommandParameters(unittest.TestCase):
|
class TestGlobalAndSubcommandParameters(TestWithoutExtensions):
|
||||||
def test_set_twice_same_value(self):
|
def test_set_twice_same_value(self):
|
||||||
"""Can set -D twice: globally and for subcommand if values are the same"""
|
"""Can set -D twice: globally and for subcommand if values are the same"""
|
||||||
|
|
||||||
@ -174,7 +184,7 @@ class TestGlobalAndSubcommandParameters(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestDeprecations(unittest.TestCase):
|
class TestDeprecations(TestWithoutExtensions):
|
||||||
def test_exit_with_error_for_subcommand(self):
|
def test_exit_with_error_for_subcommand(self):
|
||||||
try:
|
try:
|
||||||
subprocess.check_output([sys.executable, idf_py_path, "-C%s" % current_dir, "test-2"], env=os.environ)
|
subprocess.check_output([sys.executable, idf_py_path, "-C%s" % current_dir, "test-2"], env=os.environ)
|
||||||
@ -222,4 +232,4 @@ class TestDeprecations(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
main()
|
||||||
|
Reference in New Issue
Block a user