mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-22 09:01:08 +00:00
idf.py: add exit_with_error for deprecation
This commit is contained in:
@@ -174,5 +174,52 @@ class TestGlobalAndSubcommandParameters(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class TestDeprecations(unittest.TestCase):
|
||||
def test_exit_with_error_for_subcommand(self):
|
||||
try:
|
||||
subprocess.check_output([sys.executable, idf_py_path, "-C%s" % current_dir, "test-2"], env=os.environ)
|
||||
except subprocess.CalledProcessError as e:
|
||||
self.assertIn('Error: Command "test-2" is deprecated and was removed.', e.output.decode('utf-8', 'ignore'))
|
||||
|
||||
def test_exit_with_error_for_option(self):
|
||||
try:
|
||||
subprocess.check_output(
|
||||
[sys.executable, idf_py_path, "-C%s" % current_dir, "--test-5=asdf"], env=os.environ)
|
||||
except subprocess.CalledProcessError as e:
|
||||
self.assertIn(
|
||||
'Error: Option "test_5" is deprecated since v2.0 and was removed in v3.0.',
|
||||
e.output.decode('utf-8', 'ignore'))
|
||||
|
||||
def test_deprecation_messages(self):
|
||||
output = subprocess.check_output(
|
||||
[
|
||||
sys.executable,
|
||||
idf_py_path,
|
||||
"-C%s" % current_dir,
|
||||
"--test-0=a",
|
||||
"--test-1=b",
|
||||
"--test-2=c",
|
||||
"--test-3=d",
|
||||
"test-0",
|
||||
"--test-sub-0=sa",
|
||||
"--test-sub-1=sb",
|
||||
"ta",
|
||||
"test-1",
|
||||
],
|
||||
env=os.environ).decode('utf-8', 'ignore')
|
||||
|
||||
self.assertIn('Warning: Option "test_sub_1" is deprecated and will be removed in future versions.', output)
|
||||
self.assertIn(
|
||||
'Warning: Command "test-1" is deprecated and will be removed in future versions. '
|
||||
'Please use alternative command.', output)
|
||||
self.assertIn('Warning: Option "test_1" is deprecated and will be removed in future versions.', output)
|
||||
self.assertIn(
|
||||
'Warning: Option "test_2" is deprecated and will be removed in future versions. '
|
||||
'Please update your parameters.', output)
|
||||
self.assertIn('Warning: Option "test_3" is deprecated and will be removed in future versions.', output)
|
||||
self.assertNotIn('"test-0" is deprecated', output)
|
||||
self.assertNotIn('"test_0" is deprecated', output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user