Skip to content

Commit

Permalink
Merge pull request #196903 from Homebrew/q-z-cpp-heredocs
Browse files Browse the repository at this point in the history
q-z: Use C++ language-specific heredoc delimiters
  • Loading branch information
BrewTestBot authored Nov 6, 2024
2 parents 332e7f2 + fb0fed7 commit 00c17c8
Show file tree
Hide file tree
Showing 70 changed files with 148 additions and 148 deletions.
4 changes: 2 additions & 2 deletions Formula/q/qjson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <qjson-qt5/parser.h>
int main() {
QJson::Parser parser;
return 0;
}
EOS
CPP
flags = ["-I#{Formula["qt@5"].opt_include}"]
flags += if OS.mac?
[
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def caveats
SOURCES += main.cpp
EOS

(testpath/"main.cpp").write <<~EOS
(testpath/"main.cpp").write <<~CPP
#include <QCoreApplication>
#include <QDebug>
Expand All @@ -381,7 +381,7 @@ def caveats
qDebug() << "Hello World!";
return 0;
}
EOS
CPP

# Work around "error: no member named 'signbit' in the global namespace"
ENV.delete "CPATH"
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/qtkeychain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <qt6keychain/keychain.h>
int main() {
QKeychain::ReadPasswordJob job(QLatin1String(""));
return 0;
}
EOS
CPP
flags = ["-I#{Formula["qt"].opt_include}"]
flags += if OS.mac?
[
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/quazip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def install
QMAKE_RPATHDIR += #{lib}
EOS

(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <quazip/quazip.h>
int main() {
QuaZip zip;
return 0;
}
EOS
CPP

system Formula["qt"].bin/"qmake", "test.pro"
system "make"
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/quill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include "quill/Backend.h"
#include "quill/Frontend.h"
#include "quill/LogMacros.h"
Expand Down Expand Up @@ -50,7 +50,7 @@ def install
LOG_TRACE_L2(logger, "Positional arguments are {1} {0} ", "too", "supported");
LOG_TRACE_L3(logger, "Support for floats {:03.2f}", 1.23456);
}
EOS
CPP

system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}", "-o", "test", "-pthread"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/qwt-qt5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <qwt_plot_curve.h>
int main() {
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
return (curve1 == NULL);
}
EOS
CPP
if OS.mac?
system ENV.cxx, "test.cpp", "-o", "out",
"-std=c++11",
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/qwt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <qwt_plot_curve.h>
int main() {
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
return (curve1 == NULL);
}
EOS
CPP
qt = Formula["qt"]
if OS.mac?
system ENV.cxx, "test.cpp", "-o", "out",
Expand Down
4 changes: 2 additions & 2 deletions Formula/q/qxmpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def install
QMAKE_RPATHDIR += #{lib}
EOS

(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <QXmppQt6/QXmppClient.h>
int main() {
QXmppClient client;
return 0;
}
EOS
CPP

system "#{Formula["qt"].bin}/qmake", "test.pro"
system "make"
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/r3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include "r3.h"
int main() {
node * n = r3_tree_create(1);
r3_tree_free(n);
return 0;
}
EOS
CPP
system ENV.cc, "test.cpp", "-o", "test",
"-L#{lib}", "-lr3", "-I#{include}/r3"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/range-v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <range/v3/all.hpp>
#include <iostream>
#include <string>
Expand All @@ -35,7 +35,7 @@ def install
ranges::for_each( s, [](char c){ std::cout << c << " "; });
std::cout << std::endl;
}
EOS
CPP
stdlib_ldflag = OS.mac? ? "-lc++" : "-lstdc++"
flags = [stdlib_ldflag]
flags << "-stdlib=libc++" if OS.mac?
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rapidfuzz-cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <rapidfuzz/fuzz.hpp>
#include <string>
#include <iostream>
Expand All @@ -30,7 +30,7 @@ def install
std::string b = "abab";
std::cout << rapidfuzz::fuzz::ratio(a, b) << std::endl;
}
EOS
CPP
system ENV.cxx, "test.cpp", "-std=c++17", "-I#{include}", "-o", "test"
assert_equal "50", shell_output("./test").strip
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/re2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <re2/re2.h>
#include <assert.h>
int main() {
assert(!RE2::FullMatch("hello", "e"));
assert(RE2::PartialMatch("hello", "e"));
return 0;
}
EOS
CPP
system ENV.cxx, "-std=c++17", "test.cpp", "-o", "test",
"-I#{include}", "-L#{lib}", "-lre2"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rlog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <stdio.h>
#include <unistd.h>
#include <rlog/rlog.h>
Expand All @@ -52,7 +52,7 @@ def install
if (ans != 42) rWarning("ans = %i, expecting 42", ans);
rError("I'm sorry %s, I can't do that.", name);
}
EOS
CPP

expected_outputs = [
"(test.cpp:13) num = 299792458",
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rocksdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <assert.h>
#include <rocksdb/options.h>
#include <rocksdb/memtablerep.h>
Expand All @@ -69,7 +69,7 @@ def install
Options options;
return 0;
}
EOS
CPP

extra_args = []
if OS.mac?
Expand Down
8 changes: 4 additions & 4 deletions Formula/r/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ def caveats
end

test do
(testpath/"test.C").write <<~EOS
(testpath/"test.C").write <<~C
#include <iostream>
void test() {
std::cout << "Hello, world!" << std::endl;
}
EOS
C

# Test ROOT command line mode
system bin/"root", "-b", "-l", "-q", "-e", "gSystem->LoadAllLibraries(); 0"
Expand All @@ -221,14 +221,14 @@ def caveats
shell_output("#{bin}/root -l -b -n -q test.C+")

# Test linking
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <iostream>
#include <TString.h>
int main() {
std::cout << TString("Hello, world!") << std::endl;
return 0;
}
EOS
CPP
flags = %w[cflags libs ldflags].map { |f| "$(#{bin}/root-config --#{f})" }
flags << "-Wl,-rpath,#{lib}/root"
shell_output("$(#{bin}/root-config --cxx) test.cpp #{flags.join(" ")}")
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rtmidi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include "RtMidi.h"
int main(int argc, char **argv, char **env) {
RtMidiIn midiin;
RtMidiOut midiout;
std::cout << "Input ports: " << midiin.getPortCount() << "\\n"
<< "Output ports: " << midiout.getPortCount() << "\\n";
}
EOS
CPP
system ENV.cxx, "test.cpp", "-o", "test", "-std=c++11", "-I#{include}/rtmidi", "-L#{lib}", "-lrtmidi"
# Only run the test on macOS since ALSA initialization errors on Linux CI.
# ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
Expand Down
4 changes: 2 additions & 2 deletions Formula/r/rttr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def install

test do
hello_world = "Hello World"
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <iostream>
#include <rttr/registration>
Expand All @@ -52,7 +52,7 @@ def install
type::invoke("f", {});
}
// outputs: "Hello World"
EOS
CPP
system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lrttr_core", "-o", "test"
assert_match hello_world, shell_output("./test")
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/s2geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include "s2/s2loop.h"
#include "s2/s2polygon.h"
#include "s2/s2latlng.h"
Expand Down Expand Up @@ -88,7 +88,7 @@ def install
return 0;
}
EOS
CPP

system ENV.cxx, "-std=c++17", "test.cpp", "-o", "test",
"-L#{lib}", "-ls2", "-L#{Formula["abseil"].lib}", "-labsl_log_internal_message"
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/sblim-sfcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <cimc/cimc.h>
int main()
{
return 0;
}
EOS
CPP
system ENV.cxx, "test.cpp", "-L#{lib}", "-lcimcclient", "-o", "test"
system "./test"
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/scnlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include <scn/scan.h>
#include <cstdlib>
#include <string>
Expand All @@ -46,7 +46,7 @@ def install
auto [result] = scn::scan<int>(std::to_string(expected), "{}")->values();
return result == expected ? EXIT_SUCCESS : EXIT_FAILURE;
}
EOS
CPP

system ENV.cxx, "-std=c++17", "test.cpp", "-o", "test", "-I#{include}", "-L#{lib}", "-lscn"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/servus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def install

test do
# Embed "serializeable" test from the servus 1.5.0 source
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#define BOOST_TEST_MODULE servus_serializable
#include <boost/test/unit_test.hpp>
Expand Down Expand Up @@ -129,7 +129,7 @@ class SerializableObject : public servus::Serializable
// default toJson (unimplemented)
BOOST_CHECK_THROW( obj.toJSON(), std::runtime_error );
}
EOS
CPP
system ENV.cxx, "test.cpp", "-L#{lib}", "-lServus", "-DBOOST_TEST_DYN_LINK",
"-L#{Formula["boost"].opt_lib}", "-lboost_unit_test_framework",
"-std=gnu++11", "-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/sfml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def install
end

test do
(testpath/"test.cpp").write <<~EOS
(testpath/"test.cpp").write <<~CPP
#include "Time.hpp"
int main() {
sf::Time t1 = sf::milliseconds(10);
return 0;
}
EOS
CPP
system ENV.cxx, "-I#{include}/SFML/System", testpath/"test.cpp",
"-L#{lib}", "-lsfml-system", "-o", "test"
system "./test"
Expand Down
Loading

0 comments on commit 00c17c8

Please sign in to comment.