-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cygwin cygdrive prefix test #15076
Comments
From Stromeko@nexgo.deThe test for the cygdrive prefix can be simplified by using the cygpath my $prefix2 = readlink "/proc/cygdrive" if a fork and some parsing should be avoided and supporting older Cygwin |
From Stromeko@nexgo.deperl.fix-636efde.patch--- t/lib/cygwin.t.orig 2015-12-06 18:29:01.970308000 +0100
+++ t/lib/cygwin.t 2015-12-06 18:44:29.329880800 +0100
@@ -51,18 +51,14 @@
# Cygdrive mount prefix
my @flags = split(/,/, Cygwin::mount_flags('/cygdrive'));
-my $prefix = pop(@flags);
-ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
-chomp(my $prefix2 = `df -a | grep -i '^c: ' | cut -d% -f2 | xargs`);
-# we get something like "C: - - - - /cygdrive" if this isn't the entry
-# df displays free space info for
-$prefix2 =~ s/.* //;
-$prefix2 =~ s/\/c$//i;
+my $prefix1 = pop(@flags);
+ok($prefix1, "cygdrive mount prefix1 = " . (($prefix1) ? $prefix1 : '<none>'));
+chomp(my $prefix2 = `cygpath C:`); # the drive need not actually exist, so this will always work
+$prefix2 =~ s/\/c$//;
+$prefix2 = "/" unless $prefix2;
SKIP:
{
- $prefix2
- or skip("No C: entry found in df output", 1);
- is($prefix, $prefix2, 'cygdrive mount prefix');
+ is($prefix1, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2);
}
my @mnttbl = Cygwin::mount_table();
|
From Stromeko@nexgo.deRegards, Wavetables for the Terratec KOMPLEXER: |
From @tonycozOn Sun Dec 06 09:57:49 2015, Stromeko@nexgo.de wrote:
The change looks sane, though I'm not sure why you renamed $prefix. Can you supply this patch as a "git format-patch" style patch? Tony |
The RT System itself - Status changed from 'new' to 'open' |
From Stromeko@nexgo.deTony Cook via RT writes:
Just for symmetry reasons, but I have no problem with keeping it named
Can do. Regards, Samples for the Waldorf Blofeld: |
From Stromeko@nexgo.deTony Cook via RT writes:
Attached. |
From Stromeko@nexgo.de0001-perl-126834-Cygwin-cygdrive-prefix-test.patchFrom b12ceb2c68415fbe6e46390f71870fb73854f24a Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@NexGo.DE>
Date: Mon, 7 Dec 2015 19:42:37 +0100
Subject: [PATCH] [perl #126834] Cygwin cygdrive prefix test
* t/lib/cygwin.t: The test for the cygdrive prefix is simplified by
using the cygpath executable instead of parsing the output from df or
mount.
An alternative for modern Cygwin would be to use
my $prefix2 = readlink "/proc/cygdrive"
if a fork and some parsing should be avoided and supporting older Cygwin
versions is not considered important.
---
t/lib/cygwin.t | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/t/lib/cygwin.t b/t/lib/cygwin.t
index 9033d3f..174f3bd 100644
--- a/t/lib/cygwin.t
+++ b/t/lib/cygwin.t
@@ -52,13 +52,14 @@ is(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_fl
# Cygdrive mount prefix
my @flags = split(/,/, Cygwin::mount_flags('/cygdrive'));
my $prefix = pop(@flags);
-ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
-chomp(my $prefix2 = `df | grep -i '^c: ' | cut -d% -f2 | xargs`);
-$prefix2 =~ s/\/c$//i;
-if (! $prefix2) {
- $prefix2 = '/';
+ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
+chomp(my $prefix2 = `cygpath C:`); # the drive need not actually exist, so this will always work
+$prefix2 =~ s/\/c$//;
+$prefix2 = "/" unless $prefix2;
+SKIP:
+{
+ is($prefix, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2);
}
-is($prefix, $prefix2, 'cygdrive mount prefix');
my @mnttbl = Cygwin::mount_table();
ok(@mnttbl > 0, "non empty mount_table");
--
2.6.2
|
From Stromeko@nexgo.deRegards, SD adaptation for Waldorf rackAttack V1.04R1: |
From vano@mail.mipt.ru`cygpath C:\' isn't completely fool-proof as C:\ might be mounted independently. `readlink /proc/cygdrive' does look like the best solution. So, the best way I see is to use it and fall back to the heuristics if it's "Shelling out" can't be avoided unless you wish to check the registry by hand: I'll now check the Cygwin repo for /proc/cygdrive addition time vs. registry -- |
From Stromeko@nexgo.deIvan Pozdeev via perl5-porters writes:
In which case the former code would fail just the same. If you wanted,
Well, I can get behind that idea; thanks for mentioning. How about the |
From Stromeko@nexgo.de0001-perl-126834-Cygwin-cygdrive-prefix-test.patchFrom bcfee9939cab7b09a129ee72db7281c27d1ff9c3 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@NexGo.DE>
Date: Mon, 7 Dec 2015 19:42:37 +0100
Subject: [PATCH] [perl #126834] Cygwin cygdrive prefix test
* t/lib/cygwin.t: Use the /proc virtual filesystem to determine the
cygdrive prefix. If that isn't available, fall back to using the
cygpath executable instead of parsing the output from df or mount
for older Cygwin. That fallback can fail if C:\ is manually mounted
someplace else, but the former code had the same problem.
---
t/lib/cygwin.t | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/t/lib/cygwin.t b/t/lib/cygwin.t
index 9033d3f..dd2e31e 100644
--- a/t/lib/cygwin.t
+++ b/t/lib/cygwin.t
@@ -52,13 +52,16 @@ is(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_fl
# Cygdrive mount prefix
my @flags = split(/,/, Cygwin::mount_flags('/cygdrive'));
my $prefix = pop(@flags);
-ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
-chomp(my $prefix2 = `df | grep -i '^c: ' | cut -d% -f2 | xargs`);
-$prefix2 =~ s/\/c$//i;
-if (! $prefix2) {
- $prefix2 = '/';
+ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
+my $prefix2 = readlink "/pro/cygdrive";
+unless ($prefix2) {
+ # fallback to old Cygwin, the drive need not actually exist, so
+ # this will always work (but might return the wrong prefix if the
+ # user re-mounted C:\
+ chomp($prefix2 = `cygpath C:`);
+ $prefix2 = substr($prefix2, 0, -1-(length($prefix2)>2));
}
-is($prefix, $prefix2, 'cygdrive mount prefix');
+is($prefix, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2);
my @mnttbl = Cygwin::mount_table();
ok(@mnttbl > 0, "non empty mount_table");
--
2.6.2
|
From Stromeko@nexgo.deRegards, Factory and User Sound Singles for Waldorf Q+, Q and microQ: |
From Stromeko@nexgo.deAchim Gratz writes:
Sorry, the patch still had a change in I made to test the fallback… |
From Stromeko@nexgo.de0001-perl-126834-Cygwin-cygdrive-prefix-test.patchFrom bcfee9939cab7b09a129ee72db7281c27d1ff9c3 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@NexGo.DE>
Date: Mon, 7 Dec 2015 19:42:37 +0100
Subject: [PATCH] [perl #126834] Cygwin cygdrive prefix test
* t/lib/cygwin.t: Use the /proc virtual filesystem to determine the
cygdrive prefix. If that isn't available, fall back to using the
cygpath executable instead of parsing the output from df or mount
for older Cygwin. That fallback can fail if C:\ is manually mounted
someplace else, but the former code had the same problem.
---
t/lib/cygwin.t | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/t/lib/cygwin.t b/t/lib/cygwin.t
index 9033d3f..dd2e31e 100644
--- a/t/lib/cygwin.t
+++ b/t/lib/cygwin.t
@@ -52,13 +52,16 @@ is(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_fl
# Cygdrive mount prefix
my @flags = split(/,/, Cygwin::mount_flags('/cygdrive'));
my $prefix = pop(@flags);
-ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
-chomp(my $prefix2 = `df | grep -i '^c: ' | cut -d% -f2 | xargs`);
-$prefix2 =~ s/\/c$//i;
-if (! $prefix2) {
- $prefix2 = '/';
+ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
+my $prefix2 = readlink "/proc/cygdrive";
+unless ($prefix2) {
+ # fallback to old Cygwin, the drive need not actually exist, so
+ # this will always work (but might return the wrong prefix if the
+ # user re-mounted C:\
+ chomp($prefix2 = `cygpath C:`);
+ $prefix2 = substr($prefix2, 0, -1-(length($prefix2)>2));
}
-is($prefix, $prefix2, 'cygdrive mount prefix');
+is($prefix, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2);
my @mnttbl = Cygwin::mount_table();
ok(@mnttbl > 0, "non empty mount_table");
--
2.6.2
|
From Stromeko@nexgo.deRegards, Factory and User Sound Singles for Waldorf Q+, Q and microQ: |
From @tonycozOn Mon Dec 07 12:44:47 2015, Stromeko@nexgo.de wrote:
This patch doesn't seem to be against blead perl. Tony |
From Stromeko@nexgo.deTony Cook via RT writes:
Sorry, you're right -- should be fixed now. |
From Stromeko@nexgo.de0001-perl-126834-Cygwin-cygdrive-prefix-test.patchFrom 91acd29f061acccda0c13e8f47e0d82f45eea6c5 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Achim.Gratz@Stromeko.DE>
Date: Wed, 9 Dec 2015 18:59:03 +0100
Subject: [PATCH] [perl #126834] Cygwin cygdrive prefix test
* t/lib/cygwin.t: Use the /proc virtual filesystem to determine the
cygdrive prefix. If that isn't available, fall back to using the
cygpath executable instead of parsing the output from df or mount
for older Cygwin. That fallback can fail if C:\ is manually mounted
someplace else, but the former code had the same problem.
---
t/lib/cygwin.t | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/t/lib/cygwin.t b/t/lib/cygwin.t
index a619e40..ba86170 100644
--- a/t/lib/cygwin.t
+++ b/t/lib/cygwin.t
@@ -52,18 +52,16 @@ is(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_fl
# Cygdrive mount prefix
my @flags = split(/,/, Cygwin::mount_flags('/cygdrive'));
my $prefix = pop(@flags);
-ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
-chomp(my $prefix2 = `df -a | grep -i '^c: ' | cut -d% -f2 | xargs`);
-# we get something like "C: - - - - /cygdrive" if this isn't the entry
-# df displays free space info for
-$prefix2 =~ s/.* //;
-$prefix2 =~ s/\/c$//i;
-SKIP:
-{
- $prefix2
- or skip("No C: entry found in df output", 1);
- is($prefix, $prefix2, 'cygdrive mount prefix');
+ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
+my $prefix2 = readlink "/proc/cygdrive";
+unless ($prefix2) {
+ # fallback to old Cygwin, the drive need not actually exist, so
+ # this will always work (but might return the wrong prefix if the
+ # user re-mounted C:\
+ chomp($prefix2 = `cygpath C:`);
+ $prefix2 = substr($prefix2, 0, -1-(length($prefix2)>2));
}
+is($prefix, $prefix2, 'cygdrive mount prefix2 = ' . $prefix2);
my @mnttbl = Cygwin::mount_table();
ok(@mnttbl > 0, "non empty mount_table");
--
2.6.2
|
From Stromeko@nexgo.deRegards, Wavetables for the Waldorf Blofeld: |
@tonycoz - Status changed from 'open' to 'pending release' |
From Stromeko@nexgo.deTony Cook via RT writes:
Thank you. Regards, Factory and User Sound Singles for Waldorf rackAttack: |
From @khwilliamsonThank you for submitting this report. You have helped make Perl better. Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0 |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#126834 (status was 'resolved')
Searchable as RT126834$
The text was updated successfully, but these errors were encountered: