1N/A#!/usr/bin/perl -w
1N/A
1N/ABEGIN {
1N/A if( $ENV{PERL_CORE} ) {
1N/A chdir 't' if -d 't';
1N/A @INC = ('../lib', 'lib');
1N/A }
1N/A else {
1N/A unshift @INC, 't/lib';
1N/A }
1N/A}
1N/A
1N/Achdir 't';
1N/A
1N/Ause MakeMaker::Test::Utils;
1N/Ause Test::More tests => 6;
1N/Ause File::Spec;
1N/A
1N/Amy $TB = Test::More->builder;
1N/A
1N/ABEGIN { use_ok('ExtUtils::MM') }
1N/A
1N/Amy $mm = bless { NAME => "Foo" }, 'MM';
1N/Aisa_ok($mm, 'ExtUtils::MakeMaker');
1N/Aisa_ok($mm, 'ExtUtils::MM_Any');
1N/A
1N/A
1N/Asub try_oneliner {
1N/A my($code, $switches, $expect, $name) = @_;
1N/A my $cmd = $mm->oneliner($code, $switches);
1N/A $cmd =~ s{\$\(PERLRUN\)}{$^X};
1N/A
1N/A # VMS likes to put newlines at the end of commands if there isn't
1N/A # one already.
1N/A $expect =~ s/([^\n])\z/$1\n/ if $^O eq 'VMS';
1N/A
1N/A $TB->is_eq(scalar `$cmd`, $expect, $name) || $TB->diag("oneliner:\n$cmd");
1N/A}
1N/A
1N/A# Lets see how it deals with quotes.
1N/Atry_oneliner(q{print "foo'o", ' bar"ar'}, [], q{foo'o bar"ar}, 'quotes');
1N/A
1N/A# How about dollar signs?
1N/Atry_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' );
1N/A
1N/A# switches?
1N/Atry_oneliner(q{print 'foo'}, ['-l'], "foo\n", 'switches' );
1N/A
1N/A# XXX gotta rethink the newline test. The Makefile does newline
1N/A# escaping, then the shell.
1N/A