Skip to content

Commit 5e47504

Browse files
committed
002_iccp.t: mock some --version output to test clang changes
1 parent 06eb121 commit 5e47504

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

t/002_icpp.t

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,61 @@ my @METHODS = qw(
9595

9696
run_test(@$_) for @DATA;
9797

98+
# mock some compiler output
99+
my $old_capture = \&ExtUtils::CppGuess::_capture;
100+
our $CAPTURES;
101+
{
102+
no warnings "redefine";
103+
*ExtUtils::CppGuess::_capture =
104+
sub {
105+
my @cmd = @_;
106+
if (my $result = $CAPTURES->{"@cmd"}) {
107+
note "Mocking output of @cmd: $result";
108+
return $result;
109+
}
110+
goto &$old_capture;
111+
};
112+
}
113+
my @CAPS =
114+
(
115+
[
116+
{ cc => "cc", config => { ccflags => '' } },
117+
{
118+
is_sunstudio => 0,
119+
is_msvc => undef, is_gcc => undef, is_clang => 1,
120+
compiler_command => 'clang++ -xc++ -Wno-reserved-user-defined-literal',
121+
linker_flags => '-lstdc++',
122+
},
123+
{ "cc --version" => "OpenBSD clang version 10.0.1" },
124+
],
125+
[
126+
{ cc => "clang-15", config => { ccflags => '' } },
127+
{
128+
is_sunstudio => 0,
129+
is_msvc => undef, is_gcc => undef, is_clang => 1,
130+
compiler_command => 'clang++ -xc++ -Wno-reserved-user-defined-literal',
131+
linker_flags => '-lstdc++',
132+
},
133+
{ "clang-15 --version" => "Debian clang version 15.0.7" },
134+
],
135+
[
136+
{ cc => "cc", config => { ccflags => '' } },
137+
{
138+
is_sunstudio => 0,
139+
is_msvc => undef, is_gcc => 1, is_clang => 0,
140+
compiler_command => 'g++ -xc++',
141+
linker_flags => '-lstdc++',
142+
},
143+
{ "cc --version" => "cc (Debian 12.2.0-14) 12.2.0" },
144+
],
145+
);
146+
147+
for my $test (@CAPS) {
148+
my ($args, $expect, $cap) = @$test;
149+
local $CAPTURES = $cap;
150+
run_test($args, $expect);
151+
}
152+
98153
done_testing;
99154

100155
sub run_test {

0 commit comments

Comments
 (0)