Skip to content

Commit

Permalink
Attempt to compile on other platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
RauliL committed Sep 7, 2024
1 parent ff72543 commit 041a669
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
name: Checkout
- name: Build & Test
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ runner.workspace }}/build
build-type: Release
configure-options: -DCMAKE_CXX_FLAGS="-std=c++17"
run-test: true
- uses: actions/checkout@v2
name: Checkout
- name: Build & Test
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ runner.workspace }}/build
build-type: Release
configure-options: -DCMAKE_CXX_FLAGS="-std=c++17"
run-test: true
2 changes: 1 addition & 1 deletion include/peelo/xdg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace peelo::xdg

if (homedrive && *homedrive && homepath && *homepath)
{
return std::filesystem::path(homedrive) / homepath;
return T(homedrive) / homepath;
}
} else {
return userprofile;
Expand Down
26 changes: 13 additions & 13 deletions test/test_multiple_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
#include <cstdlib>
#include <functional>

#if defined(_WIN32)
# include <windows.h>
#endif

#include <peelo/xdg.hpp>

using callback_type = std::function<std::vector<std::filesystem::path>()>;

static void
test_callback(
const callback_type& callback,
const char* env_variable_name
const std::string& env_variable_name
)
{
using peelo::xdg::internal::path_separator;

unsetenv(env_variable_name);
setenv(
env_variable_name,
(
std::string("/xdg") +
path_separator +
path_separator +
"/xdg/xdg"
).c_str(),
1
);
const auto value = std::string("/xdg") + path_separator + path_separator + "/xdg/xdg";

#if defined(_WIN32)
_putenv((env_variable_name + "=" + value).c_str());
#else
unsetenv(env_variable_name.c_str());
setenv(env_variable_name.c_str(), value.c_str(), 1);
#endif

const auto result = callback();

Expand Down
12 changes: 12 additions & 0 deletions test/test_single_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <cstring>
#include <functional>

#if defined(_WIN32)
# include <windows.h>
#endif

#include <peelo/xdg.hpp>

using std::filesystem::path;
Expand All @@ -17,7 +21,11 @@ test_with_env_variable(
const char* env_variable_name
)
{
#if defined(_WIN32)
_putenv((env_variable_name + "=" + "xdg\\test").c_str());
#else
setenv(env_variable_name, "xdg/test", 1);
#endif

const auto result = callback();

Expand All @@ -32,8 +40,12 @@ test_without_env_variable(
const optional<path>& expected_result
)
{
#if defined(_WIN32)
_putenv("HOME=xdg");
#else
unsetenv(env_variable_name);
setenv("HOME", "xdg", 1);
#endif

const auto result = callback();

Expand Down

0 comments on commit 041a669

Please sign in to comment.