Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding initial unit tests to manifest parser #228

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions edkrepo_manifest_parser/test/test_edk_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import unittest
from edkrepo_manifest_parser import edk_manifest

INPUT_MANIFEST_FILE = 'test_manifest.xml'

class ManifestTest(unittest.TestCase):
def setUp(self):
self.manifest = edk_manifest.ManifestXml(INPUT_MANIFEST_FILE)

def test_parse_project_info(self):
self.assertEquals(self.manifest.project_info.codename, 'Edk2TestProject')
self.assertEquals(self.manifest.project_info.description, 'Test Project')
self.assertEquals(self.manifest.project_info.dev_leads, ['[email protected]', '[email protected]'])
self.assertEquals(self.manifest.project_info.reviewers, ['[email protected]', '[email protected]'])
self.assertEquals(self.manifest.project_info.org, 'TianoCore')
self.assertEquals(self.manifest.project_info.short_name, 'EDKII')

def test_parse_general_config(self):
self.assertEquals(self.manifest.general_config.default_combo, 'main')
self.assertEquals(self.manifest.general_config.current_combo, 'main')
self.assertEquals(self.manifest.general_config.pin_path, 'test/pins')
self.assertEquals(self.manifest.general_config.source_manifest_repo, None)

def test_parse_remotes(self):
[remote_a, remote_b] = self.manifest.remotes
self.assertEquals(remote_a.name, 'Edk2Repo')
self.assertEquals(remote_a.url, 'https://github.com/tianocore/edk2.git')
self.assertEquals(remote_b.name, 'Edk2Platforms')
self.assertEquals(remote_b.url, 'https://github.com/tianocore/edk2-platforms.git')

def test_parse_combinations(self):
combo = self.manifest.combinations[0]
self.assertEquals(combo.name, 'main')
self.assertEquals(combo.description, 'Main Combo')
self.assertFalse(combo.venv_enable)

def test_parse_githooks(self):
[githook_a, githook_b] = self.manifest.repo_hooks
self.assertEquals(githook_a.source, 'hooks/hook-wrapper')
self.assertEquals(githook_a.dest_path, '.git/hooks')
self.assertEquals(githook_a.dest_file, 'hooks/pre-push')
self.assertEquals(githook_a.remote_url, 'https://github.com/tianocore/edk2.git')
self.assertEquals(githook_b.source, 'hooks/hook-wrapper')
self.assertEquals(githook_b.dest_path, '.git/hooks')
self.assertEquals(githook_b.dest_file, 'hooks/pre-commit')
self.assertEquals(githook_b.remote_url, 'https://github.com/tianocore/edk2.git')

def test_parse_dsc_list(self):
dsc = self.manifest.dsc_list[0]
self.assertEquals(dsc, 'Edk2/IntelFsp2Pkg/IntelFsp2Pkg.dsc')

def test_parse_sparse_settings(self):
self.assertTrue(self.manifest.sparse_settings.sparse_by_default)

def test_parse_sparse_data(self):
sparse_data = self.manifest.sparse_data[0]
self.assertEquals(sparse_data.combination, None)
self.assertEquals(sparse_data.remote_name, 'Edk2Repo')
self.assertEquals(sparse_data.always_include, ['*.*'])
self.assertEquals(sparse_data.always_exclude, ['UnitTestFrameworkPkg'])

def test_parse_folder_to_folder_mappings(self):
f2f = self.manifest.folder_to_folder_mappings[0]
[f2f_mapping_a, f2f_mapping_b] = f2f.folders

self.assertEquals(f2f.project1, 'SRC')
self.assertEquals(f2f.project2, 'DST')
self.assertEquals(f2f.remote_name, 'remote')
self.assertEquals(f2f_mapping_a.project1_folder, 'SrcFspPkg')
self.assertEquals(f2f_mapping_a.project2_folder, 'DestFspPkg')
self.assertEquals(f2f_mapping_a.excludes, [])
self.assertEquals(f2f_mapping_b.project1_folder, 'SrcFspPkg/SrcFspPkg.dsc')
self.assertEquals(f2f_mapping_b.project2_folder, 'DestFspPkg/DestFspPkg.dsc')
self.assertEquals(f2f_mapping_b.excludes, [])

def test_parse_current_combo(self):
self.assertEquals(self.manifest.current_combo, 'main')

def test_parse_commit_templates(self):
self.assertEquals(self.manifest.commit_templates, {'Edk2Repo': 'Templates/template.txt'})

def test_parse_submodule_alternate_remotes(self):
submodule_redirect = self.manifest.submodule_alternate_remotes[0]
self.assertEquals(submodule_redirect.remote_name, 'Edk2Repo')
self.assertEquals(submodule_redirect.original_url, 'https://git.cryptomilk.org/projects/cmocka.git')
self.assertEquals(submodule_redirect.alternate_url, 'https://github.com/tianocore/edk2-cmocka.git')


if __name__ == "__main__":
unittest.main()
56 changes: 56 additions & 0 deletions edkrepo_manifest_parser/test/test_manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Manifest>
<ProjectInfo>
<CodeName>Edk2TestProject</CodeName>
<ShortName>EDKII</ShortName>
<Description>Test Project</Description>
<Org>TianoCore</Org>
<DevLead>[email protected]</DevLead>
<DevLead>[email protected]</DevLead>
<LeadReviewers>
<Reviewer>[email protected]</Reviewer>
<Reviewer>[email protected]</Reviewer>
</LeadReviewers>
</ProjectInfo>
<GeneralConfig>
<PinPath>test/pins</PinPath>
<DefaultCombo combination="main" />
<CurrentClonedCombo combination="main" />
<SourceManifestRepository>https://github.com/tianocore/edk2-edkrepo-manifest</SourceManifestRepository>
</GeneralConfig>
<SparseCheckout>
<SparseSettings useDsc="false" sparseByDefault="true" />
<SparseData remote="Edk2Repo">
<AlwaysInclude>*.*</AlwaysInclude>
<AlwaysExclude>UnitTestFrameworkPkg</AlwaysExclude>
</SparseData>
</SparseCheckout>
<RemoteList>
<Remote name="Edk2Repo" owner="tianocore">https://github.com/tianocore/edk2.git</Remote>
<Remote name="Edk2Platforms" owner="tianocore">https://github.com/tianocore/edk2-platforms.git</Remote>
</RemoteList>
<ClientGitHookList>
<ClientGitHook destination=".git/hooks" destination_file="hooks/pre-push" remote="Edk2Repo" source="hooks/hook-wrapper" />
<ClientGitHook destination=".git/hooks" destination_file="hooks/pre-commit" remote="Edk2Repo" source="hooks/hook-wrapper" />
</ClientGitHookList>
<CommitTemplates>
<Template remoteName="Edk2Repo">Templates/template.txt</Template>
</CommitTemplates>
<SubmoduleAlternateRemotes>
<SubmoduleAlternateRemote originalUrl="https://git.cryptomilk.org/projects/cmocka.git" remote="Edk2Repo">https://github.com/tianocore/edk2-cmocka.git</SubmoduleAlternateRemote>
</SubmoduleAlternateRemotes>
<CombinationList>
<Combination name="main" description="Main Combo">
<Source localRoot="Edk2" remote="Edk2Repo" branch="master" sparseCheckout="true" />
<Source localRoot="Edk2Platforms" remote="Edk2Platforms" branch="master" sparseCheckout="false" />
</Combination>
</CombinationList>
<FolderToFolderMappingList>
<FolderToFolderMapping project1="SRC" project2="DST" remote="remote">
<Folder project1="SourceFspPkg" project2="DestFspPkg" />
<File project1="SourceFspPkg/SourceFspPkg.dsc" project2="DestFspPkg/DestFspPkg.dsc" />
</FolderToFolderMapping>
</FolderToFolderMappingList>
<DscList>
<Dsc>Edk2/IntelFsp2Pkg/IntelFsp2Pkg.dsc</Dsc>
</DscList>
</Manifest>