Skip to content

Fixed multiple issues related to blocks and the lmove command #506

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

Merged
merged 8 commits into from
Jul 1, 2022

Conversation

abey79
Copy link
Owner

@abey79 abey79 commented Jun 30, 2022

Description

This PR aims to address multiple issues which arise from the discussion in #487, and in particular the "paint well" command listed in #501.

The first issue is a bug in blocks which, due to the structurally faulty vpype_cli.State.temp_document() context manager, could disregard the outcome of the nested commands if one such command changed the pipeline's vp.Document instance. This is solved by suppressing said context manager and rewriting the block commands' code.

A new --keep-page-size option has been added to the grid command in the process (helps for tests).

Another issue is the order of the lmove command when used like lmove all 2. Previously, the resulting ordering would be: [layer 2 content, layer 1 content, layer 3 content, etc.]. This would break the intended "paint well" pipeline. This PR fixes lmove such that the order is instead [layer 1 content, layer 2 content, layer 3 content, ...].

Finally, another minor issue was the read-only nature of the unit variable in expressions, in particular the newly introduced m. This meant that a m variable couldn't be created, leading to a confusing message. These variables are now no longer marked as read-only, and can be overwritten by expressions (with the caveat that this would, of course, break their functionality).

To address these issues and changes, multiple tests have been added, as well as the scaffolding to automatically check the consistency of output for a collection of .vpy files. New test case can now be added simply by adding new .vpy files.

Fixes #501

Checklist

  • feature/fix implemented
  • code formatting ok (black and isort)
  • mypy returns no error
  • tests added/updated and pytest succeeds
  • documentation added/updated
    • command docstring and option/argument help
    • README.md updated (Feature Overview)
    • CHANGELOG.md updated
    • added new command to reference.rst
    • RTD doc updated and building with no error (make clean && make html in docs/)

abey79 added 4 commits June 30, 2022 16:34
- Added `--keep-page-size` option to `grid` command
- API: removed `temp_document()` context manager from `vpype_cli.State()` as it was a faulty construct
- API: added equality operator to `vpype.LineCollection` and `vpype.Document` (useful for writing tests)
- Fixed issue where certain nested commands could lead totally unexpected results with blocks
- Fixed issue with the `lmove` command where order would not be respected in certain case (such as `lmove all 2`, content of layer 2 wasn't placed after content of layer 1)
- Fixed issue where expressions could not use some variable name corresponding to units (e.g. `m`). Expressions may now reuse these variable name (but that would obviously affect their subsequent use).
- Improved implementation of `vpype_cli.execute()`
- Test: added `data/test_vpy` directory where all .vpy are executed and checked against reference SVGs (using the `reference_svg` fixture).
- Tests misc:
  * added set_current_directory context manager
  * added make_line_collection factory fixture
  * added make_document factory fixture
  * moved block-related tests to `test_block.py`
  * expanded block-related tests
- Added generation of error report when `reference_svg` fixture fails
- Improved test case naming
- Updated ref SVGs
- Updated CI to save artifacts
This makes the tests more predictable.
@codecov
Copy link

codecov bot commented Jul 1, 2022

Codecov Report

Merging #506 (e8365be) into master (6a099b7) will increase coverage by 0.24%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #506      +/-   ##
==========================================
+ Coverage   94.44%   94.69%   +0.24%     
==========================================
  Files          61       63       +2     
  Lines        5457     5636     +179     
  Branches      795      810      +15     
==========================================
+ Hits         5154     5337     +183     
+ Misses        185      182       -3     
+ Partials      118      117       -1     
Impacted Files Coverage Δ
tests/test_commands.py 99.06% <ø> (-0.04%) ⬇️
vpype_cli/state.py 95.00% <ø> (-0.59%) ⬇️
vpype_cli/substitution.py 92.24% <ø> (+0.77%) ⬆️
tests/conftest.py 88.18% <100.00%> (+4.85%) ⬆️
tests/test_blocks.py 100.00% <100.00%> (ø)
tests/test_conftest.py 100.00% <100.00%> (ø)
tests/test_layers.py 100.00% <100.00%> (ø)
tests/test_model.py 100.00% <100.00%> (ø)
tests/test_reference_output.py 100.00% <100.00%> (ø)
vpype/model.py 92.43% <100.00%> (+0.23%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a099b7...e8365be. Read the comment docs.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@abey79 abey79 merged commit 08b8962 into master Jul 1, 2022
@abey79 abey79 deleted the fix-blocks-lmove branch July 1, 2022 17:38
@abey79 abey79 mentioned this pull request Jul 1, 2022
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: incorrect behaviour with block processor and metadata issue with splitdist
1 participant