summaryrefslogtreecommitdiff
path: root/tests/sources/git.py
Commit message (Collapse)AuthorAgeFilesLines
* Add Git source test for depth=1 fetch with exact tag reftmewett/git-sourceTom Mewett2020-01-241-0/+28
|
* testing: Add functions to generate yaml filesThomas Coldrick2020-01-241-52/+45
| | | | | | | Adds functions to the `buildstream.testing` package to allow plugins to dump elements and projects on the fly. Before this plugins were just accessing the private yaml API for tests and loading/dumping directly. I also allow access to just `_yaml.load()` from testing.
* exceptions: Expose ErrorDomain, ErrorLoadReasonThomas Coldrick2020-01-231-1/+1
| | | | | | | Plugin tests are already accessing this API, but using imports from private modules. For motivation for this to be exposed publicly, note that ErrorDomain is an argument for most things in runcli.py, and LoadErrorReason may be another.
* element.py: Compute whether an element is cached only on `is_cached`Benjamin Schubert2020-01-161-2/+6
| | | | | | | | | | | This removes the early call to get whether sources are locally cached in `_update_source_state` by delegating it to the call of `is_cached`. Once it is cached, the element is assumed to stay that way for the duration of the pipeline, we can therefore cache the result once it is true. Also remove `Consistency.IS_CACHED`, which is not used anywhere else.
* source.py: Remove 'get_consistency' completelyBenjamin Schubert2020-01-161-1/+1
| | | | | This is not needed now that we have 'is_resolved' and 'is_cached'. We can therefore drop all calling places and implementations of it.
* tests/sources/git.py: Add recursive submodule testTom Mewett2019-12-131-0/+40
|
* tests: Use pytest.raise() instead of checking for return codeBenjamin Schubert2019-12-021-4/+4
| | | | | | This gives a potentially more explicit understanding of what went wrong, and pytest can give better information about that exception than just us asserting the return code.
* Reformat code using BlackChandan Singh2019-11-141-564/+426
| | | | | | | As discussed over the mailing list, reformat code using Black. This is a one-off change to reformat all our codebase. Moving forward, we shouldn't expect such blanket reformats. Rather, we expect each change to already comply with the Black formatting style.
* _yaml: Split Node-related parts into 'node.pyx'Benjamin Schubert2019-07-151-2/+2
| | | | | This makes the 'Node' API public, and available for use directly for plugins.
* _yaml: Add a 'from_dict' on Node to create new nodes from dictsBenjamin Schubert2019-07-151-1/+1
| | | | | | | This new methods is here to replace the previous 'new_node_from_dict' that will be moved to a private method. Adapt all call sites to use the new 'from_dict' method.
* tests: Change all calls to _yaml.dump to _yaml.rountrip_dumpBenjamin Schubert2019-07-151-33/+33
| | | | | Now that both are equivalent, we can skip the sanitization part before the yaml call.
* _yaml: Remove 'node_set'. Now use __setitem__Benjamin Schubert2019-07-151-8/+8
| | | | | | - Implement __setitem__ on 'MappingNode' - Implement __setitem__ on 'SequenceNode' - Adapt all call sites to use the new calling way.
* _yaml: Remove 'node_get' and migrate all remaining calls to new APIBenjamin Schubert2019-07-151-6/+6
|
* _yaml: Add 'as_bool()' and 'is_none()' to ScalarNodeBenjamin Schubert2019-07-151-2/+2
| | | | | | | | | | | - 'as_bool()' casts a ScalarNode into a boolean, understanding both 'True' and 'False' as truthy-falsy values, as per node_get(type=bool) behavior - 'is_none()' allwos checking whether the scalar node contains a 'None' value. Since 'None' cannot be used when working with booleans, we need to have a way of checking for 'None' when we actually need the information of whether the value is unset. - Adapt all call places to use the new API
* _yaml: Add 'as_str()' on ScalarNode and 'get_scalar()' on MappingNodeBenjamin Schubert2019-07-151-5/+5
| | | | | | | | | | - 'get_scalar()' allows retrieving a scalar node from a mapping. - 'as_str()' casts a ScalarNode into a string (thus removing the node information). Both together, those replace 'node_get(mapping, key, type=str)' but also allow retrieving the 'Node' itself, which will allow in the future lazier provenance computation.
* _yaml: Remove useless calls to '_yaml.node_sanitize'Benjamin Schubert2019-06-251-6/+6
| | | | | | Calling '_yaml.dump' will itself call '_yaml.node_sanitize', therefore we can remove all calls to it in places where we directly after call dump.
* testing/_utils: match git methods to base classAngelos Evripiotis2019-06-181-5/+5
| | | | | | | | | | | | Update 'source_config' of Git and _SimpleGit to match the Repo base class. This ensures that they are fully substitutable Repos. Introduce 'source_config_extra' to allow explicit usage of extended functionality, which wouldn't necessarily be supported by a different subclass. By making the signatures deliberately match, we can use PyLint to ensure the signatures don't accidentally differ.
* test:utils/site: Consolidate Git environment variables in a single placeBenjamin Schubert2019-06-061-2/+1
| | | | | | | We have two different 'site' files that are redundant and both define some variables in BuildStream environment. Moving all the git related ones in a single place.
* plugintestutils: Rename 'plugintestutils' package to 'testing'phil/rename-plugintestutilsPhil Dawson2019-04-161-2/+2
| | | | | | | | | - Rename plugintestutils to testing. - Don't run the tests from bst-plugins-template. This imports buildstream.plugintestutils so will have to be disabled to get through CI. This can be re nabled once bst-plugins-template has been patched.
* testutils: move repo.py into buildstream.plugintestutilsPhil Dawson2019-04-121-1/+1
| | | | | | | | This needs to be exposed as part of the plugin author facing API so that plugin authors can define custom repo types which will can be passed to the set of tests which iterate over multiple source types. Part of the work towards #944
* _yaml.py: Remove node_containsDaniel Silverstone2019-04-041-7/+7
| | | | | | | Now that we permit `key in somenode` remove the no longer needed function to check if a node contains a key. Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
* The new YAML World OrderDaniel Silverstone2019-03-271-24/+31
| | | | | | | | | Replace YAML internals with a new Node type, and refactor everything to use it cleanly. This work was also by James Ennis <james.ennis@codethink.co.uk> Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
* tests: str(datafiles) instead of a longer thingAngelos Evripiotis2019-03-211-16/+16
| | | | | | | | | | | | | | | | | | | Replace some popular copypasta. This important-looking invocation: os.path.join(datafiles.dirname, datafiles.basename) is equivalent to this shorter invocation: project = str(datafiles) It seems like it's very popular copypasta, replace it with the shorter one thus: # Use 'gsed' or 'sed' etc. as appropriate for your system. git config --global alias.sub '!f() { git grep --name-only --null "$1" | gxargs --null gsed --in-place --expression "s/$1/$2/g" ; }; f' git sub 'os.path.join(datafiles.dirname, datafiles.basename)' 'str(datafiles)'
* tests:lint: disable 'unused-import' checks on pytest fixturesBenjamin Schubert2019-03-201-1/+1
| | | | | Pylint can't know that pytest's fixtures are used in a file and therefore reports false positives. Silencing all those errors
* tests:lint: silence redefined-outer-name in files using fixturesBenjamin Schubert2019-03-201-0/+3
| | | | | Pylint doesn't play well with pytest fixtures, we therefore need to silence this error.
* tests:lint: use set comprehensions instead of set([])Benjamin Schubert2019-03-201-3/+3
|
* tests:lint: reorder imports for consistencyBenjamin Schubert2019-03-201-1/+2
| | | | | - Remove all wrong-import-order from pylint - Order some subgroups of imports
* Let subprocess decode stdout based on localebschubert/no-subprocess-decodeBenjamin Schubert2019-03-011-8/+12
| | | | | | | | | Subprocesses can return decoded strings if we give them a "universal_newlines=True" argument. We can therefore offload that to them, and not explicitly decode output ourselves. This also fixes multiple bugs where we would not be respecting the locale used by the user, and in some cases force it to "ascii".
* tests: Remove unused importsremove-dead-codeBenjamin Schubert2019-03-011-1/+0
|
* tests: Remove unused variablesBenjamin Schubert2019-03-011-19/+19
|
* Use [a, b, *c] instead of [a, b] + c when building listbschubert/more-pythonic-list-concatBenjamin Schubert2019-03-011-3/+3
| | | | | This pattern is available from python3.5 and provides a simpler understanding of what is going on
* Expose basic api for testing external plugins.phil/plugin-testing-apiPhil Dawson2019-02-081-1/+3
| | | | | | | | | | | | | | | | | | We want external plugins to be able to make use of the core testing utils. This commit exposes the basic utilities which are currently in use in bst-external plugins. If necessary, more utilities could be exposed in the future. Moves the following files from tests/testutils/ to buildstream/plugintestingutils/: o runcli.py o integration.py As part of this, this commit makes the following changes to runcli.py and integration.py: o runcli.py: Fix linting errors o runcli.py: Add user facing documentation o Integration.py: Add user facing documentation
* Mark 'old' checkout command as obsoleteJames Ennis2019-01-221-10/+10
| | | | | | | | | | | This commit marks 'bst checkout' as a 'hidden' command. If used, the user will be prompted to use the new 'bst artifact checkout' command. All tests which used 'bst checkout' have been modified to use the new artifact sub-command. This partially solves #822.
* tests/sources/git.py: Skip tests that assume too new a gitRichard Maw2019-01-211-1/+3
| | | | | | | | | | | | | | | | | test_track_invalid_submodule depends on being able to remove a submodule by `git rm $submoduledir`, but old versions of git don't update .gitmodules so BuildStream still thinks there's a submodule present. For expediency the test is skipped rather than changed to manually remove the entry from .gitmodules if git hasn't done it, since in the common case git is new enough to do that itself. test_git_describe expects --first-parent to find another tag, but `bst track` will gracefully degrade if the option doesn't work so a different history will be retained with old versions of git. It's of marginal benefit to add additional cruft to test for different output on old versions of git that won't persist forever.
* buildstream/_gitsourcebase.py: Fix case where HEAD is taggedValentin David2019-01-161-0/+111
| | | | | `git rev-list --boundary HEAD..HEAD` does not return any boundary. So in this case we need to manually tag the HEAD as a boundary.
* buildstream/_gitsourcebase.py: Reduce git history for git describe.Valentin David2019-01-161-0/+78
| | | | | | | | | | | | Found during #833. `git rev-list --boundary tag..HEAD` unfortunately gives boundaries that are deeper than should when there is a merge commit between `tag` and `HEAD`. The common ancestory of the two parents of the merge is a boundary instead of the parent of the branch that is not traversed. `--ancestry-path` fixes this issue by restricting `git` traversing those branches.
* Introduce new "source" command groupChandan Singh2018-12-141-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following the message thread https://mail.gnome.org/archives/buildstream-list/2018-November/msg00106.html, implement a new command group called `source`. Move existing `track`, `fetch`, and the recently added `source-checkout` commands under this group. For `track` and `fetch`, this is a BREAKING change, as the old commands have been marked as obsolete. Using them will result in an error message that refers people to use the new versions, like `bst source fetch` instead of old `bst fetch`. `source-checkout` will now become `source checkout` (the dash has turned into a space), and is not a breaking change as it was added in the current development cycle. Note that the functionality to hide commands from help output was added only recently in Click, so the minimum version of Click that we now require is 7.0. Summary of changes: * _frontend/cli.py: Add `source` command group, mark previous versions as obsolete and hide them from the help output. * _frontend/complete.py: Fix completion for hidden commands. * setup.py: Bump Click minimum version to 7.0. * tests: Update to cope with the new command names. Fixes #814.
* Force updating tags when fetching git repositoryvalentindavid/git_force_fetch_tagsValentin David2018-12-111-0/+98
| | | | | | | | | When using aliases there are multiple remotes used in the cache repository. When fetching, tags are not updated if the were previously fetched from a different remote. Commits that not in a branch and only tagged do not get fetched if the tag is not fetched. Fixes #812
* tests/sources/git.py: Test invalid submodules warning appearing after trackTristan Van Berkom2018-12-061-0/+61
|
* tests/sources/git.py: Test unlisted submodules warning appearing after trackTristan Van Berkom2018-12-061-0/+63
|
* tests/sources/git.py: Testing the git:invalid-submodule warningTristan Van Berkom2018-12-061-0/+71
| | | | | | | | | | | | | | | o Test that it is not triggered in show before fetch, because we don't know the submodules yet so we cannot know if they are valid or not. o Test that it is triggered by a fetch command o Test that it is triggered by `show` after having completed a fetch command, since now we have the repository and know which specified submodules are invalid o Test all of this under warning or error conditions (parameterized for fatal-warnings)
* tests/sources/git.py: Testing the git:unlisted-submodule warningTristan Van Berkom2018-12-061-0/+73
| | | | | | | | | | | | | | o Test that it is not triggered in show before fetch, because we don't know about the unlisted submodules yet o Test that it is triggered by a fetch command o Test that it is triggered by `show` after having completed a fetch command, since now we have the repository and know about the unlisted submodule o Test all of this under warning or error conditions (parameterized for fatal-warnings)
* tests/sources/git.py: Refactor ref-not-in-track test to use parameterizationTristan Van Berkom2018-12-061-41/+17
| | | | | Instead of duplicating the whole test body, run it twice while checking for a warning or an error depending on the parameter.
* git source plugin: Track git tags and save them to reproduce a minimum ↵Valentin David2018-12-051-0/+153
| | | | | | | | | | | | | | | shallow repository Instead of tag information being fetched which can change with time, they are tracked and saved in the projects.refs/.bst. Then we re-tag automatically the closest tag so that `git describe` works and is reproducible. This new feature is opt-in with the new `track-tags` configuration, and must be used to fix modules which are broken by our new policy of omitting the `.git/` repository when staging git sources. This fixes issue #487
* tests/sources/git.py: Add track and fetch test with and without tagJürg Billeter2018-09-271-0/+47
|
* tests/sources/git.py: Add tests for REF_NOT_IN_TRACKtpollard/483Tom Pollard2018-09-031-0/+68
| | | | | Add tests that cover assert_ref_in_track & the configurable CoreWarnings REF_NOT_IN_TRACK warnings token.
* Add Error to git and ostree sources configureWilliam Salmon2018-08-171-17/+24
| | | | | | | | | Raise a error at configure time if the track and ref properties are not present in the sources. This is to address https://gitlab.com/BuildStream/buildstream/issues/471 that documented unhelpful behaviour when tracking git sources. However the issue was also identified in ostree.
* Add warning to git track if track and ref are not presentWilliam Salmon2018-08-071-0/+42
| | | | | This is to address https://gitlab.com/BuildStream/buildstream/issues/471 that documented unhelpfull behavour when tracking git sources.
* _stream.py: Add StreamError exceptionTristan Van Berkom2018-05-081-1/+1
| | | | Use Stream error for Stream errors.
* tests/sources/git.py: Test that we ignore inconsistent submodules.Tristan Van Berkom2018-03-221-0/+37
| | | | | | | Test this at `bst track` time, when encountering a new ref which adds a .gitmodules file but does not actually add the submodule, we check that the expected warning is in the stderr and that BuildStream does not error out for this.