Merge pull request #613 from burnpanck/improvement/test-on-arm64

Run test on macOS 14 with upstream clang
This commit is contained in:
Mateusz Pusz
2024-09-17 09:27:54 +09:00
committed by GitHub
4 changed files with 51 additions and 12 deletions

View File

@@ -143,6 +143,20 @@ jobs:
std_format_support: "True", std_format_support: "True",
conan-config: "", conan-config: "",
} }
- {
name: "Clang-18 on Apple M1 (arm64)",
os: macos-14,
compiler:
{
type: CLANG,
version: 18,
cc: "/opt/homebrew/opt/llvm@18/bin/clang-18",
cxx: "/opt/homebrew/opt/llvm@18/bin/clang++",
},
lib: "libc++",
cxx_modules: "False",
std_format_support: "True"
}
- { - {
name: "Apple Clang 15", name: "Apple Clang 15",
os: macos-13, os: macos-13,
@@ -196,8 +210,8 @@ jobs:
shell: bash shell: bash
run: | run: |
sudo apt install -y g++-${{ matrix.config.compiler.version }} sudo apt install -y g++-${{ matrix.config.compiler.version }}
- name: Install Clang - name: Install Clang with apt
if: matrix.config.compiler.type == 'CLANG' if: matrix.config.compiler.type == 'CLANG' && matrix.config.os != 'macos-14'
shell: bash shell: bash
working-directory: ${{ env.HOME }} working-directory: ${{ env.HOME }}
run: | run: |
@@ -205,8 +219,13 @@ jobs:
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.config.compiler.version }} sudo ./llvm.sh ${{ matrix.config.compiler.version }}
sudo apt install -y clang-tools-${{ matrix.config.compiler.version }} sudo apt install -y clang-tools-${{ matrix.config.compiler.version }}
- name: Install Clang using homebrew
if: matrix.config.compiler.type == 'CLANG' && matrix.config.os == 'macos-14'
shell: bash
run: |
brew install llvm@18
- name: Install Libc++ - name: Install Libc++
if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' && matrix.config.os != 'macos-14'
shell: bash shell: bash
run: | run: |
sudo apt install -y libc++-${{ matrix.config.compiler.version }}-dev libc++abi-${{ matrix.config.compiler.version }}-dev libunwind-${{ matrix.config.compiler.version }}-dev sudo apt install -y libc++-${{ matrix.config.compiler.version }}-dev libc++abi-${{ matrix.config.compiler.version }}-dev libunwind-${{ matrix.config.compiler.version }}-dev

View File

@@ -136,6 +136,20 @@ jobs:
cxx_modules: "False", cxx_modules: "False",
std_format_support: "True" std_format_support: "True"
} }
- {
name: "Clang-18 on Apple M1 (arm64)",
os: macos-14,
compiler:
{
type: CLANG,
version: 18,
cc: "/opt/homebrew/opt/llvm@18/bin/clang-18",
cxx: "/opt/homebrew/opt/llvm@18/bin/clang++",
},
lib: "libc++",
cxx_modules: "False",
std_format_support: "True"
}
- { - {
name: "Apple Clang 15", name: "Apple Clang 15",
os: macos-14, os: macos-14,
@@ -188,8 +202,8 @@ jobs:
shell: bash shell: bash
run: | run: |
sudo apt install -y g++-${{ matrix.config.compiler.version }} sudo apt install -y g++-${{ matrix.config.compiler.version }}
- name: Install Clang - name: Install Clang with apt
if: matrix.config.compiler.type == 'CLANG' if: matrix.config.compiler.type == 'CLANG' && matrix.config.os != 'macos-14'
shell: bash shell: bash
working-directory: ${{ env.HOME }} working-directory: ${{ env.HOME }}
run: | run: |
@@ -197,8 +211,13 @@ jobs:
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.config.compiler.version }} sudo ./llvm.sh ${{ matrix.config.compiler.version }}
sudo apt install -y clang-tools-${{ matrix.config.compiler.version }} sudo apt install -y clang-tools-${{ matrix.config.compiler.version }}
- name: Install Clang using homebrew
if: matrix.config.compiler.type == 'CLANG' && matrix.config.os == 'macos-14'
shell: bash
run: |
brew install llvm@18
- name: Install Libc++ - name: Install Libc++
if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' && matrix.config.os != 'macos-14'
shell: bash shell: bash
run: | run: |
sudo apt install -y libc++-${{ matrix.config.compiler.version }}-dev libc++abi-${{ matrix.config.compiler.version }}-dev libunwind-${{ matrix.config.compiler.version }}-dev sudo apt install -y libc++-${{ matrix.config.compiler.version }}-dev libc++abi-${{ matrix.config.compiler.version }}-dev libunwind-${{ matrix.config.compiler.version }}-dev

View File

@@ -35,7 +35,7 @@ namespace mp_units {
template<Quantity T> template<Quantity T>
struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase { struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase {
explicit AlmostEqualsMatcher(const T& target) : target_{target} {} explicit AlmostEqualsMatcher(const T& target, int n_eps) : target_{target}, n_eps_{n_eps} {}
template<std::convertible_to<T> U> template<std::convertible_to<T> U>
requires std::same_as<typename T::rep, typename U::rep> requires std::same_as<typename T::rep, typename U::rep>
@@ -48,7 +48,7 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase {
const auto y = common(other).numerical_value_in(common::unit); const auto y = common(other).numerical_value_in(common::unit);
if constexpr (treat_as_floating_point<rep>) { if constexpr (treat_as_floating_point<rep>) {
const auto maxXYOne = std::max({rep{1}, abs(x), abs(y)}); const auto maxXYOne = std::max({rep{1}, abs(x), abs(y)});
return abs(x - y) <= std::numeric_limits<rep>::epsilon() * maxXYOne; return abs(x - y) <= (n_eps_ * std::numeric_limits<rep>::epsilon()) * maxXYOne;
} else { } else {
if (x >= 0) { if (x >= 0) {
return x - 1 <= y && y - 1 <= x; return x - 1 <= y && y - 1 <= x;
@@ -71,12 +71,13 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase {
private: private:
const T& target_; const T& target_;
int n_eps_;
}; };
template<Quantity T> template<Quantity T>
AlmostEqualsMatcher<T> AlmostEquals(const T& target) AlmostEqualsMatcher<T> AlmostEquals(const T& target, int n_eps = 1)
{ {
return AlmostEqualsMatcher<T>{target}; return AlmostEqualsMatcher<T>{target, n_eps};
} }

View File

@@ -448,7 +448,7 @@ TEST_CASE("Angle trigonometric functions", "[trig][angle]")
REQUIRE_THAT(sin(0 * angle[grad]), AlmostEquals(0. * one)); REQUIRE_THAT(sin(0 * angle[grad]), AlmostEquals(0. * one));
REQUIRE_THAT(sin(100 * angle[grad]), AlmostEquals(1. * one)); REQUIRE_THAT(sin(100 * angle[grad]), AlmostEquals(1. * one));
REQUIRE_THAT(sin(200 * angle[grad]), AlmostEquals(0. * one)); REQUIRE_THAT(sin(200 * angle[grad]), AlmostEquals(0. * one, 2));
REQUIRE_THAT(sin(300 * angle[grad]), AlmostEquals(-1. * one)); REQUIRE_THAT(sin(300 * angle[grad]), AlmostEquals(-1. * one));
} }
@@ -475,7 +475,7 @@ TEST_CASE("Angle trigonometric functions", "[trig][angle]")
REQUIRE_THAT(tan(0 * angle[grad]), AlmostEquals(0. * one)); REQUIRE_THAT(tan(0 * angle[grad]), AlmostEquals(0. * one));
REQUIRE_THAT(tan(50 * angle[grad]), AlmostEquals(1. * one)); REQUIRE_THAT(tan(50 * angle[grad]), AlmostEquals(1. * one));
REQUIRE_THAT(tan(150 * angle[grad]), AlmostEquals(-1. * one)); REQUIRE_THAT(tan(150 * angle[grad]), AlmostEquals(-1. * one));
REQUIRE_THAT(tan(200 * angle[grad]), AlmostEquals(0. * one)); REQUIRE_THAT(tan(200 * angle[grad]), AlmostEquals(0. * one, 2));
} }
} }