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

(test/gurka/) Using C++17 filesystem with few changes #4664

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/gurka/gurka.cc
Expand Up @@ -28,7 +28,7 @@
#include <osmium/object_pointer_collection.hpp>
#include <osmium/osm/object_comparisons.hpp>

#include <filesystem.h>
#include <filesystem>
#include <regex>
#include <string>
#include <tuple>
Expand Down
7 changes: 4 additions & 3 deletions test/gurka/test_admin_sidewalk_crossing_override.cc
@@ -1,7 +1,8 @@
#include <filesystem>

#include <gtest/gtest.h>

#include "baldr/admin.h"
#include "filesystem.h"
#include "gurka.h"
#include "mjolnir/admin.h"
#include "mjolnir/adminbuilder.h"
Expand Down Expand Up @@ -119,8 +120,8 @@ TEST(AdminTest, TestBuildAdminFromPBF) {
// Create test/data/admin/map.pbf
const std::string workdir = "test/data/admin_belarus";

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down
6 changes: 3 additions & 3 deletions test/gurka/test_admin_uk_override.cc
@@ -1,7 +1,7 @@
#include <filesystem>
#include <gtest/gtest.h>

#include "baldr/admin.h"
#include "filesystem.h"
#include "gurka.h"
#include "mjolnir/admin.h"
#include "mjolnir/adminbuilder.h"
Expand Down Expand Up @@ -115,8 +115,8 @@ TEST(AdminTest, TestBuildAdminFromPBF) {
// Create test/data/admin/map.pbf
const std::string workdir = "test/data/admin_uk";

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down
10 changes: 6 additions & 4 deletions test/gurka/test_config_speed.cc
Expand Up @@ -2,6 +2,8 @@
#include "src/mjolnir/speed_assigner.h"
#include <gtest/gtest.h>

#include <filesystem>

using namespace valhalla;

TEST(Standalone, DefaultSpeedConfig) {
Expand Down Expand Up @@ -129,9 +131,9 @@ TEST(Standalone, DefaultSpeedConfig) {
}
}

if (!filesystem::create_directories("test/data"))
if (!std::filesystem::exists("test/data") && !std::filesystem::create_directories("test/data"))
throw std::runtime_error("couldn't create directories");
filesystem::remove("test/data/speed_config.json");
std::filesystem::remove("test/data/speed_config.json");

{
std::ofstream speed_config("test/data/speed_config.json");
Expand Down Expand Up @@ -281,9 +283,9 @@ TEST(Standalone, SuburbanSpeedConfig) {
}
}

if (!filesystem::create_directories("test/data"))
if (!std::filesystem::exists("test/data") && !std::filesystem::create_directories("test/data"))
throw std::runtime_error("couldn't create directories");
filesystem::remove("test/data/speed_config_suburban.json");
std::filesystem::remove("test/data/speed_config_suburban.json");

{
std::ofstream speed_config("test/data/speed_config_suburban.json");
Expand Down
6 changes: 4 additions & 2 deletions test/gurka/test_elevation.cc
Expand Up @@ -5,6 +5,8 @@
#include "loki/worker.h"
#include "midgard/pointll.h"

#include <filesystem>

#include <gtest/gtest.h>
#include <prime_server/http_protocol.hpp>
#include <prime_server/prime_server.hpp>
Expand Down Expand Up @@ -125,8 +127,8 @@ TEST(Standalone, ElevationCompareToSkadi) {
}
}

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down
16 changes: 8 additions & 8 deletions test/gurka/test_landmarks.cc
Expand Up @@ -248,8 +248,8 @@ TEST(LandmarkTest, TestBuildDatabase) {
}

TEST(LandmarkTest, TestParseLandmarks) {
if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down Expand Up @@ -393,8 +393,8 @@ TEST(LandmarkTest, TestTileStoreLandmarks) {
}

TEST(LandmarkTest, TestAddLandmarksToTiles) {
if (!filesystem::exists(workdir_tiles)) {
bool created = filesystem::create_directories(workdir_tiles);
if (!std::filesystem::exists(workdir_tiles)) {
bool created = std::filesystem::create_directories(workdir_tiles);
EXPECT_TRUE(created);
}

Expand Down Expand Up @@ -429,8 +429,8 @@ TEST(LandmarkTest, TestAddLandmarksToTiles) {
// hierarchy max level", and "Could not compute FileSuffix for GraphId with invalid tile
// id:0/245760/0". We need to fix it in the future.
TEST(LandmarkTest, DISABLED_ErrorTest) {
if (!filesystem::exists(workdir_tiles)) {
bool created = filesystem::create_directories(workdir_tiles);
if (!std::filesystem::exists(workdir_tiles)) {
bool created = std::filesystem::create_directories(workdir_tiles);
EXPECT_TRUE(created);
}

Expand Down Expand Up @@ -508,8 +508,8 @@ TEST(LandmarkTest, TestLandmarksInManeuvers) {
const std::string db_path = workdir + "/landmarks.sqlite";
const std::string pbf = workdir + "/map.pbf";

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down
5 changes: 3 additions & 2 deletions test/gurka/test_route_summary.cc
@@ -1,4 +1,5 @@
#include <cmath>
#include <filesystem>
#include <sstream>
#include <sys/mman.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -112,7 +113,7 @@ TEST(TestRouteSummary, GetSummary) {
gurka::assert::osrm::expect_summaries(result, {expected_route_summary0, expected_route_summary1,
expected_route_summary2});

filesystem::remove_all(workdir);
std::filesystem::remove_all(workdir);
}

TEST(TestRouteSummary, DupSummaryFix) {
Expand Down Expand Up @@ -202,5 +203,5 @@ TEST(TestRouteSummary, DupSummaryFix) {
const std::string expected_route_summary1 = "RT 1, RT 2, RT 4";
gurka::assert::osrm::expect_summaries(result, {expected_route_summary0, expected_route_summary1});

filesystem::remove_all(workdir);
std::filesystem::remove_all(workdir);
}
6 changes: 4 additions & 2 deletions test/gurka/test_stop_signs.cc
@@ -1,3 +1,5 @@
#include <filesystem>

#include "gurka.h"
#include "test/test.h"
#include <gtest/gtest.h>
Expand Down Expand Up @@ -72,8 +74,8 @@ TEST(Standalone, StopSigns) {

const std::string workdir = "test/data/gurka_stop_signs";

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down
6 changes: 4 additions & 2 deletions test/gurka/test_traffic_signals.cc
@@ -1,3 +1,5 @@
#include <filesystem>

#include "gurka.h"
#include "test/test.h"
#include <gtest/gtest.h>
Expand Down Expand Up @@ -73,8 +75,8 @@ TEST(Standalone, TrafficSignals) {

const std::string workdir = "test/data/gurka_traffic_signals";

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down
6 changes: 4 additions & 2 deletions test/gurka/test_yield_signs.cc
@@ -1,3 +1,5 @@
#include <filesystem>

#include "gurka.h"
#include "test/test.h"
#include <gtest/gtest.h>
Expand Down Expand Up @@ -72,8 +74,8 @@ TEST(Standalone, yieldSigns) {

const std::string workdir = "test/data/gurka_yeild_signs";

if (!filesystem::exists(workdir)) {
bool created = filesystem::create_directories(workdir);
if (!std::filesystem::exists(workdir)) {
bool created = std::filesystem::create_directories(workdir);
EXPECT_TRUE(created);
}

Expand Down