1#!/usr/bin/perl -w
2
3BEGIN {
4    unshift @INC, 't/lib/';
5}
6
7use strict;
8use warnings;
9use File::Temp qw[tempdir];
10my $tmpdir = tempdir( DIR => 't', CLEANUP => 1 );
11use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
12chdir $tmpdir;
13
14my $Is_VMS = $^O eq 'VMS';
15
16use File::Spec;
17
18use Test::More tests => 4;
19
20my $dir = File::Spec->catdir("some", "dir");
21my @cd_args = ($dir, "command1", "command2");
22
23{
24    package Test::MM_Win32;
25    use ExtUtils::MM_Win32;
26    our @ISA = qw(ExtUtils::MM_Win32);
27
28    my $mm = bless {}, 'Test::MM_Win32';
29
30    {
31        local *make = sub { "nmake" };
32        $mm->_clear_maketype_cache;
33
34        my @dirs = (File::Spec->updir) x 2;
35        my $expected_updir = File::Spec->catdir(@dirs);
36
37        ::is $mm->cd(@cd_args),
38qq{cd $dir
39	command1
40	command2
41	cd $expected_updir}, 'nmake';
42    }
43
44    {
45        local *make = sub { "dmake" };
46        $mm->_clear_maketype_cache;
47
48        ::is $mm->cd(@cd_args),
49qq{cd $dir && command1
50	cd $dir && command2}, 'dmake';
51    }
52}
53
54{
55    is +ExtUtils::MM_Unix->cd(@cd_args),
56qq{cd $dir && command1
57	cd $dir && command2}, 'Unix';
58}
59
60SKIP: {
61    skip("VMS' cd requires vmspath which is only on VMS", 1) unless $Is_VMS;
62
63    use ExtUtils::MM_VMS;
64    is +ExtUtils::MM_VMS->cd(@cd_args),
65q{startdir = F$Environment("Default")
66	Set Default [.some.dir]
67	command1
68	command2
69	Set Default 'startdir'}, 'VMS';
70}
71