Skip to content

Commit

Permalink
Tools: idf_tools.py prints URL before starting the download
Browse files Browse the repository at this point in the history
This helps users with poor Internet connection to be able to cancel the
download and download it in another way.

Closes espressif#8625
  • Loading branch information
dobairoland authored and antmak committed Sep 8, 2022
1 parent a3ab8da commit ec78f25
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tools/test_idf_tools/test_idf_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import json
import os
import re
import shutil
import sys
import tempfile
Expand Down Expand Up @@ -111,13 +112,13 @@ def assert_tool_installed(self, output, tool, tool_version, tool_archive_name=No
if tool_archive_name is None:
tool_archive_name = tool
self.assertIn('Installing %s@' % tool + tool_version, output)
self.assertIn('Downloading %s' % tool_archive_name, output)
self.assertRegex(output, re.compile(rf'Downloading \S+/{tool_archive_name}'))

def assert_tool_not_installed(self, output, tool, tool_version, tool_archive_name=None):
if tool_archive_name is None:
tool_archive_name = tool
self.assertNotIn('Installing %s@' % tool + tool_version, output)
self.assertNotIn('Downloading %s' % tool_archive_name, output)
self.assertNotRegex(output, re.compile(rf'Downloading \S+/{tool_archive_name}'))

def run_idf_tools_with_action(self, action):
output_stream = StringIO()
Expand Down Expand Up @@ -152,7 +153,7 @@ def test_usage_basic(self):
self.assert_tool_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))

output = self.run_idf_tools_with_action(['check'])
Expand Down Expand Up @@ -190,7 +191,7 @@ def test_tools_for_esp32(self):
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))

output = self.run_idf_tools_with_action(['check'])
Expand Down Expand Up @@ -224,7 +225,7 @@ def test_tools_for_esp32c3(self):
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))

output = self.run_idf_tools_with_action(['check'])
Expand Down Expand Up @@ -257,7 +258,7 @@ def test_tools_for_esp32s2(self):
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))

output = self.run_idf_tools_with_action(['check'])
Expand Down Expand Up @@ -291,7 +292,7 @@ def test_tools_for_esp32s3(self):
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))

output = self.run_idf_tools_with_action(['check'])
Expand Down

0 comments on commit ec78f25

Please sign in to comment.