From a65a487d997f3f27d141aada8f6678e3d4ea9397 Mon Sep 17 00:00:00 2001 From: Vitaly Slobodin Date: Thu, 6 Nov 2014 18:30:34 +0300 Subject: [PATCH] Fix invalid directory path for Windows. https://github.com/ariya/phantomjs/issues/12715 --- test/fs-spec-03.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/fs-spec-03.js b/test/fs-spec-03.js index 841cdc51..1f4f2b5c 100644 --- a/test/fs-spec-03.js +++ b/test/fs-spec-03.js @@ -1,7 +1,8 @@ describe("Files and Directories API", function() { var TEST_DIR = "testdir", TEST_FILE = "testfile", - START_CWD = fs.workingDirectory; + START_CWD = fs.workingDirectory, + system = require('system'); it("should create a new temporary directory and change the Current Working Directory to it", function() { expect(fs.makeDirectory(TEST_DIR)).toBeTruthy(); @@ -24,9 +25,18 @@ describe("Files and Directories API", function() { it("should copy Content of the '/test/' Directory in a temporary directory, compare with the original and then remove", function() { var phantomLibraryPathListingLength = fs.list(phantom.libraryPath).length; - fs.copyTree(phantom.libraryPath, "/tmp/"+TEST_DIR); - expect(phantomLibraryPathListingLength === fs.list("/tmp/"+TEST_DIR).length); - fs.removeTree("/tmp/"+TEST_DIR); + var targetDirectory = '/tmp/'; + + if (system.os.name === 'windows') { + targetDirectory = system.env['TMP']; + if (targetDirectory.indexOf('\\', targetDirectory.length - '\\'.length) === -1) { + targetDirectory += '\\'; + } + } + + fs.copyTree(phantom.libraryPath, targetDirectory + TEST_DIR); + expect(phantomLibraryPathListingLength === fs.list(targetDirectory + TEST_DIR).length); + fs.removeTree(targetDirectory + TEST_DIR); }); // TODO: test the actual functionality once we can create symlink.