-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deploy: fix symlinking failing if git commit ID differed in number of…
… digits Git repos could use different number of digits to describe a commit dependning on if there is a collision. Fix symlinking to be indepent on the ID used.
- Loading branch information
1 parent
c11011d
commit 6d665b6
Showing
7 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import unittest | ||
import tempfile | ||
import tarfile | ||
|
||
from distutils.dir_util import copy_tree | ||
from string import Template | ||
from esp_docs.deploy_docs import build_doc_tarball | ||
|
||
|
||
class TestBuildTarball(unittest.TestCase): | ||
BUILD_DIR_TEMPLATE_PATH = '_build_deploy' | ||
PDF_NAME_TEMPLATE = Template('esp-idf-$lang-$ver-esp32.pdf') | ||
VERSION = 'v5.1-dev-50-g790aa40c38' | ||
|
||
LANGUAGES = ['en', 'zh_CN'] | ||
|
||
def setUp(self): | ||
self.temp_dir = tempfile.TemporaryDirectory() | ||
|
||
copy_tree(self.BUILD_DIR_TEMPLATE_PATH, self.temp_dir.name) | ||
|
||
def tearDown(self): | ||
self.temp_dir.cleanup() | ||
|
||
def check_file_exists(self, tarball_path, file_names): | ||
with tarfile.open(tarball_path) as f: | ||
output = f.getnames() | ||
for name in file_names: | ||
self.assertTrue(any(name in o for o in output)) | ||
|
||
def test_build_tarball_tag(self): | ||
version_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver=self.VERSION, lang=lang) for lang in self.LANGUAGES] | ||
tarball_path, _ = build_doc_tarball('v4.1.0', None, self.temp_dir.name) | ||
|
||
self.check_file_exists(tarball_path, version_pdfs) | ||
|
||
def test_build_tarball_latest(self): | ||
latest_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver='latest', lang=lang) for lang in self.LANGUAGES] | ||
version_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver=self.VERSION, lang=lang) for lang in self.LANGUAGES] | ||
tarball_path, _ = build_doc_tarball('latest', self.VERSION, self.temp_dir.name) | ||
|
||
self.check_file_exists(tarball_path, version_pdfs) | ||
self.check_file_exists(tarball_path, latest_pdfs) | ||
|
||
def test_build_tarball_stable(self): | ||
stable_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver='stable', lang=lang) for lang in self.LANGUAGES] | ||
version_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver=self.VERSION, lang=lang) for lang in self.LANGUAGES] | ||
tarball_path, _ = build_doc_tarball('stable', self.VERSION, self.temp_dir.name) | ||
|
||
self.check_file_exists(tarball_path, version_pdfs) | ||
self.check_file_exists(tarball_path, stable_pdfs) | ||
|
||
# Different git repos using different numbers of digits for a commit ID | ||
# depending on how many is needed for a unique description | ||
# Check symlink succeeds even if they dont fully match | ||
def test_build_tarball_latest_short_sha1(self): | ||
latest_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver='latest', lang=lang) for lang in self.LANGUAGES] | ||
version_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver=self.VERSION, lang=lang) for lang in self.LANGUAGES] | ||
|
||
version_short_sha1 = self.VERSION[:-1] | ||
tarball_path, _ = build_doc_tarball('latest', version_short_sha1, self.temp_dir.name) | ||
|
||
self.check_file_exists(tarball_path, version_pdfs) | ||
self.check_file_exists(tarball_path, latest_pdfs) | ||
|
||
def test_build_tarball_latest_long_sha1(self): | ||
latest_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver='latest', lang=lang) for lang in self.LANGUAGES] | ||
version_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver=self.VERSION, lang=lang) for lang in self.LANGUAGES] | ||
|
||
version_long_sha1 = self.VERSION + '5' | ||
tarball_path, _ = build_doc_tarball('latest', version_long_sha1, self.temp_dir.name) | ||
|
||
self.check_file_exists(tarball_path, version_pdfs) | ||
self.check_file_exists(tarball_path, latest_pdfs) | ||
|
||
def test_build_tarball_latest_random_sha(self): | ||
latest_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver='latest', lang=lang) for lang in self.LANGUAGES] | ||
version_pdfs = [self.PDF_NAME_TEMPLATE.substitute(ver=self.VERSION, lang=lang) for lang in self.LANGUAGES] | ||
|
||
version_long_sha1 = 'ra1n-dom-ID' | ||
tarball_path, _ = build_doc_tarball('latest', version_long_sha1, self.temp_dir.name) | ||
|
||
self.check_file_exists(tarball_path, version_pdfs) | ||
self.check_file_exists(tarball_path, latest_pdfs) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |