Skip to content

[skip-changelog] Set test environment directory as CLI WorkingDir #1886

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 3 commits into from
Sep 27, 2022

Conversation

MatteoPologruto
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)

What kind of change does this PR introduce?

Infrastructure Enhancement

What is the new behavior?

By default, the working directory is the one containing the test.go file. This causes problems when executing commands that have to create files specifically in the working directory, because they either must be deleted manually or the user has to be aware of it and defer a deleting instruction. Furthermore, it messes with tests using relative paths. Setting the environment directory as the CLI's WorkingDir prevents the above mentioned issues from occurring.

Does this PR introduce a breaking change, and is titled accordingly?

No


See how to contribute

@MatteoPologruto MatteoPologruto added type: enhancement Proposed improvement topic: infrastructure Related to project infrastructure labels Sep 20, 2022
@MatteoPologruto MatteoPologruto self-assigned this Sep 20, 2022
@cmaglie
Copy link
Member

cmaglie commented Sep 21, 2022

>>> Running: ../../../arduino-cli core update-index
    arduino-cli.go:188: 
        	Error Trace:	/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/arduino-cli.go:188
        	            				/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/arduino-cli.go:150
        	            				/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/daemon_test.go:38
        	            				/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/daemon_compile_test.go:100
        	Error:      	Received unexpected error:
        	            	fork/exec ../../../arduino-cli: no such file or directory

Once you change the working directory we cannot start anymore the cli from a relative path like ../../../arduino-cli. You must obtain the absolute path before assigning it:

		ArduinoCLIPath:         FindRepositoryRootPath(t).Join("arduino-cli"),

probably the best way forward is to let FindRepositoryRootPath to return an absolute path.

@MatteoPologruto MatteoPologruto force-pushed the cli-working-dir branch 2 times, most recently from 26063d9 to 019d971 Compare September 26, 2022 15:19
By default, the working directory is the one containing the test.go file. This causes problems when executing commands that have to create files specifically in the working directory, because they either must be deleted manually or the user has to be aware of it and defer a deleting instruction. Furthermore, it messes with tests using relative paths.
Setting the environment directory as the CLI's WorkingDir prevents the above mentioned issues from occurring.
@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Base: 36.58% // Head: 36.66% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (12ea44c) compared to base (5730e2e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1886      +/-   ##
==========================================
+ Coverage   36.58%   36.66%   +0.08%     
==========================================
  Files         231      231              
  Lines       19696    19702       +6     
==========================================
+ Hits         7206     7224      +18     
+ Misses      11659    11650       -9     
+ Partials      831      828       -3     
Flag Coverage Δ
unit 36.66% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/integrationtest/arduino-cli.go 85.66% <100.00%> (+0.31%) ⬆️
arduino/monitor/monitor.go 47.36% <0.00%> (+6.31%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MatteoPologruto MatteoPologruto marked this pull request as ready for review September 26, 2022 15:56
@MatteoPologruto
Copy link
Contributor Author

>>> Running: ../../../arduino-cli core update-index
    arduino-cli.go:188: 
        	Error Trace:	/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/arduino-cli.go:188
        	            				/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/arduino-cli.go:150
        	            				/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/daemon_test.go:38
        	            				/home/runner/work/arduino-cli/arduino-cli/internal/integrationtest/daemon/daemon_compile_test.go:100
        	Error:      	Received unexpected error:
        	            	fork/exec ../../../arduino-cli: no such file or directory

Once you change the working directory we cannot start anymore the cli from a relative path like ../../../arduino-cli. You must obtain the absolute path before assigning it:

		ArduinoCLIPath:         FindRepositoryRootPath(t).Join("arduino-cli"),

probably the best way forward is to let FindRepositoryRootPath to return an absolute path.

It should be fixed now. Thanks for the suggestion!

@MatteoPologruto MatteoPologruto merged commit baa322f into arduino:master Sep 27, 2022
@MatteoPologruto MatteoPologruto deleted the cli-working-dir branch September 27, 2022 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: infrastructure Related to project infrastructure type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants