Skip to content

Commit 44a4056

Browse files
authored
Test With GCC On MacOS (#12)
* Test with GCC on MacOS * Fix GCC warning * Try Lua 5.4 on Linux
1 parent 1a9b2a5 commit 44a4056

File tree

6 files changed

+31
-12
lines changed

6 files changed

+31
-12
lines changed

.github/workflows/buildAndTest-Linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
lua:
1212
[
1313
"luajit libluajit-5.1-dev libluajit-5.1-2",
14+
"liblua5.4-dev lua5.4",
1415
"liblua5.3-dev lua5.3",
1516
"liblua5.2-dev lua5.2",
1617
"liblua5.1-0-dev lua5.1",

.github/workflows/buildAndTest-MacOS.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ jobs:
88
strategy:
99
matrix:
1010
lua: ["lua", "luajit"]
11+
compiler: ["gcc", "clang"]
1112
steps:
1213
- uses: "actions/checkout@v4"
1314
- name: "Install Dependencies"
1415
run: |
1516
brew install ${{ matrix.lua }} luarocks
17+
18+
if [[ "${{ matrix.compiler }}" = "gcc" ]]; then
19+
brew install gcc
20+
luarocks config "variables.CMAKE_C_COMPILER" "$(brew --prefix)/bin/gcc-13"
21+
luarocks config "variables.CMAKE_CXX_COMPILER" "$(brew --prefix)/bin/g++-13"
22+
fi
23+
1624
luarocks install luaunit
1725
- name: "Build Project"
18-
run: "luarocks make"
26+
run: |
27+
export CXX_COMPILER="$(brew --prefix)/bin/g++-13"
28+
export C_COMPILER="$(brew --prefix)/bin/gcc-13"
29+
CXX="$CXX_COMPILER" CC="$C_COMPILER" luarocks make
1930
- name: "Test Project"
2031
run: "lua tests/tests.lua"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Brewfile.lock.json
1111
.vscode/
1212
.nova/
1313
.vim/
14+
node_modules
1415

1516
# Test files
1617
test.lua

src/decoding/decoding.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ void insertNodeInTable(
1212
auto v = std::string(*node->as_string());
1313
try {
1414
luaTable[std::get<std::string>(keyOrIndex)] = v;
15-
} catch (std::bad_variant_access) { luaTable[std::get<size_t>(keyOrIndex)] = v; }
15+
} catch (std::bad_variant_access const &) {
16+
luaTable[std::get<size_t>(keyOrIndex)] = v;
17+
}
1618
break;
1719
}
1820

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

4143
try {
4244
luaTable[std::get<std::string>(keyOrIndex)] = v;
43-
} catch (std::bad_variant_access) { luaTable[std::get<size_t>(keyOrIndex)] = v; }
45+
} catch (std::bad_variant_access const &) {
46+
luaTable[std::get<size_t>(keyOrIndex)] = v;
47+
}
4448

4549
break;
4650
}
@@ -50,7 +54,9 @@ void insertNodeInTable(
5054

5155
try {
5256
luaTable[std::get<std::string>(keyOrIndex)] = v;
53-
} catch (std::bad_variant_access) { luaTable[std::get<size_t>(keyOrIndex)] = v; }
57+
} catch (std::bad_variant_access const &) {
58+
luaTable[std::get<size_t>(keyOrIndex)] = v;
59+
}
5460

5561
break;
5662
}
@@ -63,7 +69,7 @@ void insertNodeInTable(
6369

6470
try {
6571
luaTable[std::get<std::string>(keyOrIndex)] = newLTable;
66-
} catch (std::bad_variant_access) {
72+
} catch (std::bad_variant_access const &) {
6773
luaTable[std::get<size_t>(keyOrIndex)] = newLTable;
6874
}
6975

@@ -78,7 +84,7 @@ void insertNodeInTable(
7884

7985
try {
8086
luaTable[std::get<std::string>(keyOrIndex)] = newLTable;
81-
} catch (std::bad_variant_access) {
87+
} catch (std::bad_variant_access const &) {
8288
luaTable[std::get<size_t>(keyOrIndex)] = newLTable;
8389
}
8490

@@ -95,7 +101,7 @@ void insertNodeInTable(
95101
v.toTable(t);
96102
luaTable[std::get<std::string>(keyOrIndex)] = t;
97103
}
98-
} catch (std::bad_variant_access) {
104+
} catch (std::bad_variant_access const &) {
99105
if (options.temporalTypesAsUserData) {
100106
luaTable[std::get<size_t>(keyOrIndex)] = v;
101107
} else {
@@ -118,7 +124,7 @@ void insertNodeInTable(
118124
v.toTable(t);
119125
luaTable[std::get<std::string>(keyOrIndex)] = t;
120126
}
121-
} catch (std::bad_variant_access) {
127+
} catch (std::bad_variant_access const &) {
122128
if (options.temporalTypesAsUserData) {
123129
luaTable[std::get<size_t>(keyOrIndex)] = v;
124130
} else {
@@ -145,7 +151,7 @@ void insertNodeInTable(
145151
dt.toTable(t);
146152
luaTable[std::get<std::string>(keyOrIndex)] = t;
147153
}
148-
} catch (std::bad_variant_access) {
154+
} catch (std::bad_variant_access const &) {
149155
if (options.temporalTypesAsUserData) {
150156
luaTable[std::get<size_t>(keyOrIndex)] = dt;
151157
} else {

src/encoding/encoding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void unpack(
1515
try {
1616
auto t = std::get<std::tuple<toml::table *, std::string>>(tableOrArray);
1717
tableFunc(std::get<0>(t), std::get<1>(t));
18-
} catch (std::bad_variant_access) {
18+
} catch (std::bad_variant_access const &) {
1919
auto a = std::get<toml::array *>(tableOrArray);
2020
arrayFunc(a);
2121
}

src/toml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ extern "C" {
157157
tomlToLuaTable(tomlTable, luaTable, options);
158158

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

0 commit comments

Comments
 (0)