[2/2] cmd/tests: Correctly compute script path for root directories
Frédéric Delanoy
frederic.delanoy at gmail.com
Sun Mar 9 12:50:23 CDT 2014
Test runner was adding an extraneous backlash for root directories.
This causes test failures in a corner case where test script is run from a drive root directory,
which happens on win2000 testbot machine, among others.
---
programs/cmd/tests/batch.c | 10 ++++++++--
programs/cmd/tests/test_builtins.cmd | 7 +++++++
programs/cmd/tests/test_builtins.cmd.exp | 3 +++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index c011d70..9df0bc5 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -459,8 +459,14 @@ START_TEST(batch)
drive[0] = workdir[0];
drive[1] = workdir[1]; /* Should be ':' */
memcpy(path, workdir + drive_len, (workdir_len - drive_len) * sizeof(drive[0]));
- path[workdir_len - drive_len] = '\\';
- path_len = workdir_len - drive_len + 1;
+
+ /* Only add trailing backslash to 'path' for non-root directory */
+ if (workdir_len - drive_len > 1) {
+ path[workdir_len - drive_len] = '\\';
+ path_len = workdir_len - drive_len + 1;
+ } else {
+ path_len = 1; /* \ */
+ }
shortpath_len = GetShortPathNameA(path, shortpath,
sizeof(shortpath)/sizeof(shortpath[0]));
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 1d1eea4..16fdd43 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -308,6 +308,13 @@ set WINE_FOO=
echo ------------ Testing variable expansion ------------
call :setError 0
+echo ~p0 should be path containing batch file
+echo %~p0
+mkdir dummydir
+cd dummydir
+echo %~p0
+cd ..
+rmdir dummydir
echo ~dp0 should be directory containing batch file
echo %~dp0
mkdir dummydir
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index f64f3e4..828a651 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -259,6 +259,9 @@ foo
'jim'
'apple"banana"grape'
------------ Testing variable expansion ------------
+~p0 should be path containing batch file
+ at path@
+ at path@
~dp0 should be directory containing batch file
@drive@@path@
@drive@@path@
--
1.9.0
More information about the wine-patches
mailing list