summaryrefslogtreecommitdiff
path: root/tests/internals
Commit message (Collapse)AuthorAgeFilesLines
* cascache.py: Use a shebang that won't fail on /bin/bash-less systemsTristan Maat2019-11-151-4/+4
| | | | | | `#!/usr/bin/env bash` should generally be used instead to avoid breaking on systems that do not *have* a `/bin/bash`. This is just a test, but rather annoying on my machine.
* Reformat code using BlackChandan Singh2019-11-1411-551/+450
| | | | | | | 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.
* tests: remove mark.in_subprocessAngelos Evripiotis2019-10-222-11/+0
| | | | | It seems we don't need this anymore, thanks to cleaning up gRPC background threads.
* testutils/context.py: Mock tasks instead of accepting NonesTristan Maat2019-10-101-7/+8
| | | | | | | | | | | | To ensure that we only disable element loading task progress reporting for very specific code paths, we need to teach the test suite to be a bit smarter. For this reason we now mock a _Task object and return it in our mock context's relevant method invocations. Other code paths that deliberately invoke the loader without task reporting now mark their loads with NO_PROGRESS.
* cascache.py: Save casd logs in a file for retrievalBenjamin Schubert2019-10-041-0/+39
| | | | | Save all casd logs in a log file under its cas/ directory, and keep only the last 10 of them.
* cascache.py: Send message in case of unclean termination of buildbox-casdBenjamin Schubert2019-10-021-0/+63
| | | | | | | This adds messages in the various mis-termination of Buildbox-casd, to notify users that something might have gone wrong there. It also adds a few tests to validate the various behaviors.
* tests/internals/storage_vdir_import.py: Reduce number of test casestmewett/test-in-subprocessTom Mewett2019-08-301-9/+4
| | | | | | | | In changing the tests to use in_subprocess, they were modified to do parametrization over both variables instead of looping over one in the test itself. The purpose of the original code was to reduce the number of test cases printed in the output. I have hence attempted to remove superfluous test cases.
* tests: Modify all tests using subprocesses to use in_subprocess markTom Mewett2019-08-302-130/+29
| | | | | | | Additionally, test code that was previous executed by a subfunction (in the forked process) has been folded into the test function itself, as separating it is now redundant. This removes some duplicate code for setting up the context and project, etc.
* tests/internals/storage_vdir_import.py: Terminate casd at end of testJürg Billeter2019-08-201-128/+150
|
* tests/internals/storage.py: Use context manager for casd terminationJürg Billeter2019-08-201-16/+19
|
* tests/internals/storage_vdir_import.py: Run tests in subprocessJürg Billeter2019-08-201-7/+66
| | | | | This is in preparation for buildbox-casd, which will disallow local CAS cache writes from the main process (gRPC).
* tests/internals/storage.py: Run tests in subprocessJürg Billeter2019-08-201-5/+55
| | | | | This is in preparation for buildbox-casd, which will disallow local CAS cache writes from the main process (gRPC).
* Fix descend can not follow symlinksWilliam Salmon2019-07-251-1/+141
|
* node: Add 'get_str_list' on 'MappingNode'Benjamin Schubert2019-07-171-3/+3
| | | | | | `mapping.get_sequence(...).as_str_list()` is a very common pattern seen both in plugins and the core. Adding a helper to reduce the number of operations will make usage smoother
* tests/internals/pluginloading.py: Use dummy_context()Jürg Billeter2019-07-161-22/+19
|
* tests/internals/loader.py: Use dummy_context()Jürg Billeter2019-07-161-32/+17
|
* tests/internals/context.py: Use dummy_context()Jürg Billeter2019-07-161-4/+5
|
* node: Rename 'copy' to 'clone'Benjamin Schubert2019-07-151-1/+1
| | | | | | | | A 'clone' operation has an implicit understanding that it is expensive, which is not the case of a 'copy' operation, which is more usually a shallow copy. Therefore renaming to 'clone'
* _yaml: Split Node-related parts into 'node.pyx'Benjamin Schubert2019-07-152-21/+21
| | | | | This makes the 'Node' API public, and available for use directly for plugins.
* _yaml: Set 'MappingNode' public-private APIBenjamin Schubert2019-07-151-7/+7
| | | | | | | - _composite -> __composite (internal) - composite -> _composite (BuildStream private) - composite_under -> _composite_under (BuildStream private) - get -> _get (internal)
* _yaml: Mark attributes in ProvenanceInformation as Buildstream-privateBenjamin Schubert2019-07-151-4/+4
| | | | | Users should not need to get access to any of those, and should only need access to the ProvenanceInformation to print it.
* _yaml: Remove 'node_get_provenance' and add 'Node.get_provenance'Benjamin Schubert2019-07-151-8/+8
| | | | | | | | This replaces the helper method by adding a 'get_provenance' on the node directly - Adapt all call sites - Delay getting provenance wherever possible without major refactor
* _yaml: Remove 'indices' from 'node_get_provenance'Benjamin Schubert2019-07-151-3/+3
| | | | | | | | | With nodes being propagated better, we now don't need to extract provenance beforehand. Therefore removing the ability to provide indiced when getting provenance. - Also add 'scalar_at' on 'SequenceNode', in order to fetch a scalar node at a specific indice
* _yaml: Move 'value' of Node in each sub nodeBenjamin Schubert2019-07-151-7/+14
| | | | | | | | This allows us to type its value more strictly, allowing for more efficient access. - Also implement 'node_at' on 'SequenceNode', to allow some tests to test some internals generically.
* _yaml: Remove 'node_validate' and replace by 'MappingNode.validate_keys'Benjamin Schubert2019-07-151-3/+3
| | | | - adapt all call sites to use the new API
* _yaml: Create 'from_dict' on Node and remove node creation methodsBenjamin Schubert2019-07-151-1/+1
| | | | | | | Using 'Node.from_dict({})' can replace new_empty_node, and the rest is not needed anymore. - Adapt all call sites
* _yaml: Remove 'node_extend_list' and add 'SequenceNode.append'Benjamin Schubert2019-07-151-14/+0
| | | | | | | There was a single place using 'node_extend_list', which we can replace more easily with 'SequenceNode.append'. Also rewrite _projectrefs.py:_lookup to use the new API more effectively
* _yaml: Add a 'from_dict' on Node to create new nodes from dictsBenjamin Schubert2019-07-151-16/+16
| | | | | | | 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.
* _yaml: Move 'node_composite' to a method on 'MappingNode'Benjamin Schubert2019-07-151-7/+7
| | | | | - Also take care of node_composite_move in the same way. - Adapt all calling places
* tests/yaml: Stop using 'composite_dict' and use 'composite' insteadBenjamin Schubert2019-07-151-7/+7
| | | | | 'composite_dict' is a more internal method and we don't really need to access it there
* _yaml: Remove 'node_find_target' and replace by 'MappingNode.find'Benjamin Schubert2019-07-151-2/+2
|
* _yaml: Remove 'node_set'. Now use __setitem__Benjamin Schubert2019-07-151-5/+4
| | | | | | - Implement __setitem__ on 'MappingNode' - Implement __setitem__ on 'SequenceNode' - Adapt all call sites to use the new calling way.
* _yaml: Remove 'node_copy' and add 'Node.copy()'Benjamin Schubert2019-07-151-1/+1
| | | | Also adaprt every part of the code calling it
* _yaml: Remove 'node_get' and migrate all remaining calls to new APIBenjamin Schubert2019-07-151-17/+15
|
* _yaml: Add 'as_int()' on ScalarNodeBenjamin Schubert2019-07-151-1/+1
| | | | | | - Add the 'as_int()' method on 'ScalarNode' to replace 'node_get(mapping, key, int)' - Adapt all call sites to use the new API
* _yaml: Add 'as_str()' on ScalarNode and 'get_scalar()' on MappingNodeBenjamin Schubert2019-07-151-13/+13
| | | | | | | | | | - '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: add 'get_mapping()' to MappingNodeBenjamin Schubert2019-07-151-4/+4
| | | | | | | | This allows to get a mapping node from another 'MappingNode', replacing 'node_get(my_mapping, key, type=dict)' Also changes all places where 'node_get' was called like that by the new API.
* Refactor, use context.messenger directlyAngelos Evripiotis2019-07-052-2/+2
| | | | | | Instead of having methods in Context forward calls on to the Messenger, have folks call the Messenger directly. Remove the forwarding methods in Context.
* Refactor: message handlers take 'is_silenced'Angelos Evripiotis2019-07-052-2/+2
| | | | | | | | Remove the need to pass the Context object to message handlers, by passing what is usually requested from the context instead. This paves the way to sharing less information with some child jobs - they won't need the whole context object, just the messenger.
* _yaml.pyx: Forbid expected_type=Mapping, and remove isinstance checkBenjamin Schubert2019-06-031-8/+7
| | | | | | | | | | | Calls to `isinstance` can be particularily costly. Using type() is much faster. The only known case where the `isinstance` was useful is for dictionnaries where we would ask for a 'Mapping' instead. Disallowing 'Mapping' for expected_type considerably speeds up the calls to this functions. Also add into NEWS
* _yaml: Cythonize and internalize NodeBenjamin Schubert2019-05-291-7/+7
| | | | | | | | | | | Node used to be a NamedTuple that we used to access by index for speed reasons. Moving to an extension class allows us to access attributes by name, making the code easier to read and less error prone. Moreover, we do gain speed and memory by doing this move. Also fix a few places where we would not have an entire `Node` object but were instead just returning a tuple, missing some entries.
* tests/context.py: Normalize path of XDG_CACHEBenjamin Schubert2019-05-241-1/+1
| | | | | | | | | When running tests without --basetemp ./tmp, the path to the XDG_CACHE will not be normalized, and we check that it is equal to the normalized version of it. This test only passes because it assumed "--basetemp ./tmp". Now, it would work whatever the basetemp.
* _yaml.py: Remove node_containsDaniel Silverstone2019-04-041-2/+2
| | | | | | | 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-274-75/+299
| | | | | | | | | 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>
* YAML Cache: Remove the YAML CacheDaniel Silverstone2019-03-271-28/+8
| | | | | | | The new YAML world order doesn't need the YAML cache, so remove it before we begin the change. Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
* tests: str(datafiles) instead of a longer thingAngelos Evripiotis2019-03-212-11/+11
| | | | | | | | | | | | | | | | | | | 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: silence redefined-outer-name in files using fixturesBenjamin Schubert2019-03-203-0/+9
| | | | | Pylint doesn't play well with pytest fixtures, we therefore need to silence this error.
* tests:lint: fix all unused-import from pylintBenjamin Schubert2019-03-201-1/+0
| | | | | Removes all the ones thare were not needed Whitelist the ones that are actually needed for side effects
* tests:lint: Raise exception instead of using 'assert False' for errorsBenjamin Schubert2019-03-201-1/+3
| | | | | This fixes a inconsistent-return-statements from pylint and makes it easier to understand what is happening
* tests:lint: don't use mutable default variablesBenjamin Schubert2019-03-201-1/+1
|