Skip to content

Commit

Permalink
Test With GCC On MacOS (#12)
Browse files Browse the repository at this point in the history
* Test with GCC on MacOS
* Fix GCC warning
* Try Lua 5.4 on Linux
  • Loading branch information
LebJe authored Jan 3, 2024
1 parent 1a9b2a5 commit 44a4056
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/buildAndTest-Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
lua:
[
"luajit libluajit-5.1-dev libluajit-5.1-2",
"liblua5.4-dev lua5.4",
"liblua5.3-dev lua5.3",
"liblua5.2-dev lua5.2",
"liblua5.1-0-dev lua5.1",
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/buildAndTest-MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ jobs:
strategy:
matrix:
lua: ["lua", "luajit"]
compiler: ["gcc", "clang"]
steps:
- uses: "actions/checkout@v4"
- name: "Install Dependencies"
run: |
brew install ${{ matrix.lua }} luarocks
if [[ "${{ matrix.compiler }}" = "gcc" ]]; then
brew install gcc
luarocks config "variables.CMAKE_C_COMPILER" "$(brew --prefix)/bin/gcc-13"
luarocks config "variables.CMAKE_CXX_COMPILER" "$(brew --prefix)/bin/g++-13"
fi
luarocks install luaunit
- name: "Build Project"
run: "luarocks make"
run: |
export CXX_COMPILER="$(brew --prefix)/bin/g++-13"
export C_COMPILER="$(brew --prefix)/bin/gcc-13"
CXX="$CXX_COMPILER" CC="$C_COMPILER" luarocks make
- name: "Test Project"
run: "lua tests/tests.lua"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Brewfile.lock.json
.vscode/
.nova/
.vim/
node_modules

# Test files
test.lua
Expand Down
24 changes: 15 additions & 9 deletions src/decoding/decoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ void insertNodeInTable(
auto v = std::string(*node->as_string());
try {
luaTable[std::get<std::string>(keyOrIndex)] = v;
} catch (std::bad_variant_access) { luaTable[std::get<size_t>(keyOrIndex)] = v; }
} catch (std::bad_variant_access const &) {
luaTable[std::get<size_t>(keyOrIndex)] = v;
}
break;
}

Expand All @@ -24,7 +26,7 @@ void insertNodeInTable(
} else {
luaTable[std::get<std::string>(keyOrIndex)] = v.get();
}
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
if (options.formattedIntsAsUserData && v.flags() != toml::value_flags::none) {
luaTable[std::get<size_t>(keyOrIndex)] = TOMLInt(v, v.flags());
} else {
Expand All @@ -40,7 +42,9 @@ void insertNodeInTable(

try {
luaTable[std::get<std::string>(keyOrIndex)] = v;
} catch (std::bad_variant_access) { luaTable[std::get<size_t>(keyOrIndex)] = v; }
} catch (std::bad_variant_access const &) {
luaTable[std::get<size_t>(keyOrIndex)] = v;
}

break;
}
Expand All @@ -50,7 +54,9 @@ void insertNodeInTable(

try {
luaTable[std::get<std::string>(keyOrIndex)] = v;
} catch (std::bad_variant_access) { luaTable[std::get<size_t>(keyOrIndex)] = v; }
} catch (std::bad_variant_access const &) {
luaTable[std::get<size_t>(keyOrIndex)] = v;
}

break;
}
Expand All @@ -63,7 +69,7 @@ void insertNodeInTable(

try {
luaTable[std::get<std::string>(keyOrIndex)] = newLTable;
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
luaTable[std::get<size_t>(keyOrIndex)] = newLTable;
}

Expand All @@ -78,7 +84,7 @@ void insertNodeInTable(

try {
luaTable[std::get<std::string>(keyOrIndex)] = newLTable;
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
luaTable[std::get<size_t>(keyOrIndex)] = newLTable;
}

Expand All @@ -95,7 +101,7 @@ void insertNodeInTable(
v.toTable(t);
luaTable[std::get<std::string>(keyOrIndex)] = t;
}
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
if (options.temporalTypesAsUserData) {
luaTable[std::get<size_t>(keyOrIndex)] = v;
} else {
Expand All @@ -118,7 +124,7 @@ void insertNodeInTable(
v.toTable(t);
luaTable[std::get<std::string>(keyOrIndex)] = t;
}
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
if (options.temporalTypesAsUserData) {
luaTable[std::get<size_t>(keyOrIndex)] = v;
} else {
Expand All @@ -145,7 +151,7 @@ void insertNodeInTable(
dt.toTable(t);
luaTable[std::get<std::string>(keyOrIndex)] = t;
}
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
if (options.temporalTypesAsUserData) {
luaTable[std::get<size_t>(keyOrIndex)] = dt;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/encoding/encoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void unpack(
try {
auto t = std::get<std::tuple<toml::table *, std::string>>(tableOrArray);
tableFunc(std::get<0>(t), std::get<1>(t));
} catch (std::bad_variant_access) {
} catch (std::bad_variant_access const &) {
auto a = std::get<toml::array *>(tableOrArray);
arrayFunc(a);
}
Expand Down
2 changes: 1 addition & 1 deletion src/toml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ extern "C" {
tomlToLuaTable(tomlTable, luaTable, options);

return luaTable.push();
} catch (std::bad_variant_access) { return std::get<int>(res); }
} catch (std::bad_variant_access const &) { return std::get<int>(res); }
} catch (std::exception & e) {
return luaL_error(
L, (std::string("An error occurred during decoding: ") + e.what()).c_str());
Expand Down

0 comments on commit 44a4056

Please sign in to comment.