Skip to content
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

Add functions and objects for Temporary Directories #244

Merged
merged 11 commits into from
Sep 13, 2021

Conversation

mjcarroll
Copy link
Contributor

@mjcarroll mjcarroll commented Aug 31, 2021

🎉 Functions for interacting with temporary directories

Closes #232. Split from #238 to make a version that should be portable to all ign-common4 platforms.

Summary

Adds free functions and a RAII object for interacting with operating system temporary directories. This is useful for writing tests or utilities that need to access a temporary location that can be cleaned up at the end of execution, rather than using build artifact directories or users' home folders.

Free Functions:

  • tempDirectoryPath() - retrieve OS-specific location of temporary directory
  • createTempDirectory() - create a directory in the tempDirectoryPath, expanding template strings where necessary.

Obejcts:

  • TempDirectory - Object that will create a temporary directory and optionally clean it up when it goes out of scope.

Test it

Usage is demonstrated in the TempDirectory_TEST.cc unit tests.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

Signed-off-by: Michael Carroll <michael@openrobotics.org>
@github-actions github-actions bot added 🏢 edifice Ignition Edifice 🏯 fortress Ignition Fortress labels Aug 31, 2021
@mjcarroll mjcarroll self-assigned this Aug 31, 2021
@mjcarroll mjcarroll requested a review from chapulina August 31, 2021 18:26
Signed-off-by: Michael Carroll <michael@openrobotics.org>
@mjcarroll mjcarroll force-pushed the mjcarroll/temp_directory branch from d4a60be to c379ef3 Compare September 2, 2021 20:23
@codecov
Copy link

codecov bot commented Sep 2, 2021

Codecov Report

Merging #244 (62f03df) into ign-common4 (9694f89) will decrease coverage by 0.02%.
The diff coverage is 78.57%.

❗ Current head 62f03df differs from pull request most recent head 3a6da4e. Consider uploading reports for the commit 3a6da4e to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##           ign-common4     #244      +/-   ##
===============================================
- Coverage        77.03%   77.00%   -0.03%     
===============================================
  Files               74       75       +1     
  Lines            10586    10655      +69     
===============================================
+ Hits              8155     8205      +50     
- Misses            2431     2450      +19     
Impacted Files Coverage Δ
src/TempDirectory.cc 78.26% <78.26%> (ø)
src/Console.cc 84.80% <100.00%> (ø)
src/Filesystem.cc 73.88% <0.00%> (-2.23%) ⬇️

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 9694f89...3a6da4e. Read the comment docs.

@chapulina chapulina added the beta Targeting beta release of upcoming collection label Sep 8, 2021
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I just have minor comments, but LGTM.

Signed-off-by: Michael Carroll <michael@openrobotics.org>
…obotics/ign-common into mjcarroll/temp_directory
Signed-off-by: Michael Carroll <michael@openrobotics.org>
mjcarroll and others added 3 commits September 13, 2021 08:10
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
@mjcarroll mjcarroll force-pushed the mjcarroll/temp_directory branch from 98a1b50 to 386d21d Compare September 13, 2021 13:10
Signed-off-by: Michael Carroll <michael@openrobotics.org>

Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@mjcarroll
Copy link
Contributor Author

Failure in focal CI is due to flaky test that uses timings.

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjcarroll
Copy link
Contributor Author

@mjcarroll
Copy link
Contributor Author

@osrf-jenkins retest this please

Signed-off-by: Michael Carroll <michael@openrobotics.org>
@mjcarroll mjcarroll requested a review from ahcorde September 13, 2021 18:44
@mjcarroll
Copy link
Contributor Author

@ahcorde should be good now. windows.h has to be first, which breaks when alphabetized.

@chapulina chapulina dismissed ahcorde’s stale review September 13, 2021 22:39

Windows is fixed

@chapulina chapulina merged commit d06ed33 into ign-common4 Sep 13, 2021
@chapulina chapulina deleted the mjcarroll/temp_directory branch September 13, 2021 22:40
@@ -17,6 +17,9 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE
${ignition-math${IGN_MATH_VER}_INCLUDE_DIRS})

target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC
${ignition-utils${IGN_UTILS_VER}_INCLUDE_DIRS})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means ign-utils1 is now required by the core ignition-common4 library. we should update the find_package call to make this dependency REQUIRED

scpeters added a commit that referenced this pull request Sep 15, 2021
It is used in a core header since #244.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters
Copy link
Member

this pull request may not work properly on debian buster with armhf: #255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🏢 edifice Ignition Edifice 🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An API for getting temp path in Filesystem.hh
4 participants