*** Settings ***
Library OperatingSystem
Library String
*** Keywords ***
| Run Git
| | [Arguments] | ${path} | ${args}
| | ${rc} | ${output} = | Run And Return Rc And Output | git -C ${path} ${args}
| | Should Be Equal As Integers | ${rc} | 0
| | [Return] | ${output}
| Create Test Directory
| | ${dir} = | Normalize Path | ${CURDIR}/subcomponent-system-tests-dir
| | Remove Directory | ${dir} | recursive=True
| | Create Directory | ${dir}
| | [Return] | ${dir}
| Run Subcomponent
| | [Arguments] | ${testdir} | ${args}
| | ${subcompoonent} = | Get Environment Variable | SUBCOMPONENT_TEST_BIN
| | ${rc} | ${output} = | Run And Return Rc And Output | ${subcompoonent} --debug -C ${testdir} ${args}
| | Log | ${output} | INFO
| | [Return] | ${rc}
| Run Subcomponent With File
| | [Arguments] | ${testdir} | ${file} | ${args}
| | ${rc} = | Run Subcomponent | ${testdir} | --file=${file} ${args}
| | [Return] | ${rc}
| Check Subcomponent With File
| | [Arguments] | ${testdir} | ${file} | ${args}
| | ${rc} = | Run Subcomponent With File | ${testdir} | ${file} | ${args}
| | Should Be Equal As Integers | ${rc} | 0
| Subcomponent Fetch
| | [Arguments] | ${testdir} | ${file} | ${args}=
| | ${rc} = | Run Subcomponent With File | ${testdir} | ${file} | fetch ${args}
| | Should Be Equal As Integers | ${rc} | 0
| Subcomponent Template
| | [Arguments] | ${testdir} | ${args}=
| | ${rc} = | Run Subcomponent | ${testdir} | template ${args}
| | Should Be Equal As Integers | ${rc} | 0
| Check Template Is Consistant
| | [Arguments] | ${testdir}
| | Directory Should Not Be Empty | ${testdir}/subcomponent
| | File Should Exist | ${testdir}/subcomponent/components.sub
| Git Checkout
| | [Arguments] | ${path} | ${ref} | ${args}=
| | ${rc} = | Run And Return Rc | git -C ${path} checkout ${args} ${ref}
| | Should Be Equal As Integers | ${rc} | 0
| | Check Git Tag | ${path} | tag-d
| Check Git Branch
| | [Arguments] | ${path} | ${branch}
| | ${output} = | Run Git | ${path} | rev-parse --abbrev-ref HEAD
| | Should Be Equal | ${output} | ${branch}
| Check Git Hash
| | [Arguments] | ${path} | ${hash}
| | ${output} = | Run Git | ${path} | rev-parse HEAD
| | Should Be Equal | ${output} | ${hash}
| Check Git Tag
| | [Arguments] | ${path} | ${tag}
| | ${output_a} = | Run Git | ${path} | rev-parse HEAD
| | ${output_b} = | Run Git | ${path} | rev-parse ${tag}
| | ${output} = | Run Git | ${path} | describe --tags
| | Should Be Equal | ${output_a} | ${output_b}
| | Should Be Equal | ${output} | ${tag}
| Check Git Shallow
| | [Arguments] | ${path}
| | ${output} = | Run Git | ${path} | rev-list --count --all
| | Should Be Equal As Integers | ${output} | 1
| Check Git Submodules Are Updated
| | [Arguments] | ${path}
| | ${output} = | Run Git | ${path} | submodule status
| | ${lead} = | Get Substring | ${output} | 0 | 1
| | Should Be Equal | ${lead.strip()} | ${EMPTY}
| Check Git Submodules Are Not Updated
| | [Arguments] | ${path}
| | ${output} = | Run Git | ${path} | submodule status
| | ${lead} = | Get Substring | ${output} | 0 | 1
| | Should Be Equal | ${lead} | -
| Get Hash Of File
| | [Arguments] | ${file} | ${method}
| | ${rc} | ${output} = | Run And Return Rc And Output | ${method} ${file}
| | Should Be Equal As Integers | ${rc} | 0
| | @{words} = | Split String | ${output}
| | [Return] | @{words}[0]
*** Test Cases ***
| Checking Template
| | ${testdir} = | Create Test Directory
| | Subcomponent Template | ${testdir}
| | Check Template Is Consistant | ${testdir}
| | ${rc} = | Run Subcomponent | ${testdir} | fetch
| | Should Be Equal As Integers | ${rc} | 0
| Git Cloning Checks
| | ${testdir} = | Create Test Directory
| | Subcomponent Fetch | ${testdir} | ${CURDIR}/configs/multiple-git.sub
| |
| | Check Git Branch | ${testdir}/test-repo-master | master
| | Check Git Submodules Are Not Updated | ${testdir}/test-repo-master
| |
| | Check Git Branch | ${testdir}/test-repo-branch-a | branch-a
| |
| | Check Git Tag | ${testdir}/test-repo-tag-d | tag-d
| |
| | Check Git Hash | ${testdir}/test-repo-commit | c468926e34c362ccd5cca7b4daf94fb795a88712
| |
| | Check Git Branch | ${testdir}/test-repo-shallow | branch-submodule-no-update
| | Check Git Submodules Are Updated | ${testdir}/test-repo-shallow
| | Check Git Shallow | ${testdir}/test-repo-shallow
| | Check Git Shallow | ${testdir}/test-repo-shallow/evil
| Git Updating Checks
| | ${testdir} = | Create Test Directory
| | Subcomponent Fetch | ${testdir} | ${CURDIR}/configs/one-no-shallow.sub
| |
| | Check Git Branch | ${testdir}/test-repo | master
| | Git Checkout | ${testdir}/test-repo | tag-d
| | Subcomponent Fetch | ${testdir} | ${CURDIR}/configs/one-no-shallow.sub
| | Check Git Branch | ${testdir}/test-repo | master
| Artifacts Checks
| | ${testdir} = | Create Test Directory
| | ${archive} = | Set Variable | ${testdir}/terminology-0.4.0.tar.gz
| | ${final} = | Set Variable | ${testdir}/terminology-0.4.0
| |
| | Subcomponent Fetch | ${testdir} | ${CURDIR}/configs/artifacts.sub
| | File Should Exist | ${archive}
| | Directory Should Exist | ${final}
| | ${md5} = | Get Hash Of File | ${archive} | md5sum
| | ${sha1} = | Get Hash Of File | ${archive} | sha1sum
| | ${sha256} = | Get Hash Of File | ${archive} | sha256sum
| | ${sha512} = | Get Hash Of File | ${archive} | sha512sum
| | Should Be Equal | ${md5} | 5a2eee4849d4fa44db4caf743b3beb37
| | Should Be Equal | ${sha1} | 528cb1cf1137a95a62cc1ab9019c0f58176ee1fa
| | Should Be Equal | ${sha256} | 63f2d1fa584ecda6c4ef61b05b8956415feb955c4bb13c0872c11d98024dcfc6
| | Should Be Equal | ${sha512} | 4b00ed0a02f8058f40e88f2527eb31fb7fe8bbc8572680ecaf0478ce3635b59264e7668626cf5ca63843e3e1ee3e9b40386adcb775eba05026dcc76c310c5049
| Hooks Checks
| | ${testdir} = | Create Test Directory
| |
| | Subcomponent Fetch | ${testdir} | ${CURDIR}/configs/hooks.sub
| |
| | Check Subcomponent With File | ${testdir} | ${CURDIR}/configs/hooks.sub | common
| | File Should Exist | ${testdir}/b/common-from-B
| | File Should Exist | ${testdir}/a/common-from-A
| |
| | Check Subcomponent With File | ${testdir} | ${CURDIR}/configs/hooks.sub | b-only
| | File Should Exist | ${testdir}/b/b-only