Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

remove test_data/config_dirs, create it on the fly #1216

Merged
merged 1 commit into from
May 24, 2019

Conversation

xcheng-here
Copy link
Contributor

those data are used for unit test of config module,
easy to create in unit test, not necessary put these
files in git repository

@xcheng-here xcheng-here requested review from pattivacek and lbonn May 22, 2019 12:40
@xcheng-here xcheng-here force-pushed the master branch 2 times, most recently from 83da02d to 0022607 Compare May 22, 2019 16:45
@codecov-io
Copy link

codecov-io commented May 22, 2019

Codecov Report

Merging #1216 into master will decrease coverage by 6.22%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1216      +/-   ##
==========================================
- Coverage   85.59%   79.36%   -6.23%     
==========================================
  Files         231      168      -63     
  Lines       17392    10029    -7363     
==========================================
- Hits        14886     7960    -6926     
+ Misses       2506     2069     -437
Impacted Files Coverage Δ
src/libaktualizr-posix/ipuptanesecondary.cc 82.66% <0%> (-4%) ⬇️
src/libaktualizr/uptane/directorrepository.cc 95.71% <0%> (-2.86%) ⬇️
src/aktualizr_primary/secondary.cc 86.3% <0%> (-1.37%) ⬇️
src/libaktualizr/bootloader/bootloader.cc 62.22% <0%> (-0.94%) ⬇️
src/libaktualizr/storage/sqlstorage.cc 75.67% <0%> (-0.13%) ⬇️
src/libaktualizr/utilities/utils.h 90.9% <0%> (ø) ⬆️
src/libaktualizr/storage/sqlstorage_base.h 100% <0%> (ø) ⬆️
src/libaktualizr/crypto/crypto_test.cc
tests/leak_test.cc
src/sota_tools/rate_controller_test.cc
... and 64 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 8c523ef...b030f85. Read the comment docs.

/* Parse multiple config files in a directory. */
TEST(config, OneDir) {
Config config(std::vector<boost::filesystem::path>{"tests/test_data/config_dirs/one_dir"});
TemporaryDirectory temp_dir;
std::vector<std::string> &&dirs = generate_multi_config(temp_dir);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have a lot of assignments to r-value references like that in our code. Can you explain why it would help?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No special reason. In my understanding, r-value reference could avoid an unnecessary copy and that function could return an unamed variant in stack. I believe it also works if I declare variant out side the generate_multi_config() function and pass it's reference into that function, basically the cost of those two ways are same.

@@ -169,19 +169,35 @@ TEST(config, TomlConsistentNonempty) {
EXPECT_EQ(conf_str1, conf_str2);
}

static std::vector<std::string> generate_multi_config(TemporaryDirectory &temp_dir) {
Utils::writeFile((temp_dir / "a_dir/a.toml"), std::string("[storage]\npath = \"path_a\"\n\n[pacman]\nos = \"os_a\""));
Copy link
Contributor

Choose a reason for hiding this comment

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

For a bit more readability, it could use the same style as in the TwoTomlCorrectness test, where new lines are reflected in the source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thanks, I'll modify it.

std::string("[storage]\npath = \"latest_path\"\n\n[provision]\nprovision_path = \"y_prov_path\""));
Utils::writeFile((temp_dir / "b_dir/z.txt"), std::string("[storage]\npath = \"this is path from text file\""));

return std::vector<std::string>{(temp_dir / "a_dir").c_str(), (temp_dir / "b_dir").c_str()};
Copy link
Contributor

Choose a reason for hiding this comment

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

boost::filesystem::path has a .string() method which converts into std::string. If you use c_str(), it would probably do two conversions needlessly.

@lbonn
Copy link
Contributor

lbonn commented May 23, 2019

It looks like the reason codecov is showing a big coverage decrease is that your branch is based on fef78cc, which is a few days old and did not include Mike's new test. If you rebase your branch on master, it should show better numbers.

those data are used for unit test of config module,
easy to create in unit test, not necessary put these
files in git repositoryt push --force-with-lease origin master

Signed-off-by: cheng.xiang <ext-cheng.xiang@here.com>
@lbonn lbonn self-requested a review May 23, 2019 16:04
@lbonn lbonn merged commit 6fb7e74 into advancedtelematic:master May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants