This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch janpio-e2e_speedup
in repository https://gitbox.apache.org/repos/asf/cordova-windows.git

commit c4444981bae968974e93c96b4b2d60c3e60e30d1
Author: Jan Piotrowski <piotrow...@gmail.com>
AuthorDate: Wed Feb 14 17:26:00 2018 +0100

    try to speedup e2e tests by not regenerating the project for each test but 
copy it from a template folder
---
 spec/e2e/endtoend.spec.js | 53 ++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/spec/e2e/endtoend.spec.js b/spec/e2e/endtoend.spec.js
index 97dbf41..89df2f7 100644
--- a/spec/e2e/endtoend.spec.js
+++ b/spec/e2e/endtoend.spec.js
@@ -31,38 +31,67 @@ var PluginInfo = require('cordova-common').PluginInfo;
 describe('Cordova create and build', function () {
 
     var projectFolder = 'testcreate 応用';
+    var projectTemplateName = 'project template for e2e tests';
     var buildDirectory = path.join(__dirname, '../..');
+    var projectDirectory = path.join(buildDirectory, projectFolder);
+    var projectTemplateDirectory = path.join(buildDirectory, 
projectTemplateName);
     var appPackagesFolder = path.join(buildDirectory, projectFolder, 
'AppPackages');
     var buildScriptPath = '"' + path.join(buildDirectory, projectFolder, 
'cordova', 'build') + '"';
     var prepareScriptPath = '"' + path.join(buildDirectory, projectFolder, 
'cordova', 'prepare') + '"';
 
-    var silent = false;
-
     function verifySubDirContainsFile (subDirName, fileName, count) {
         count = typeof count !== 'undefined' ? count : 1;
-
+    
         var subDir = path.join(appPackagesFolder, subDirName);
         var packages = shell.ls(subDir);
         expect(packages.filter(function (file) { return file.match(fileName); 
}).length).toBe(count);
     }
-
+    
     function _expectExist (fileNamePattern, count) {
         count = typeof count !== 'undefined' ? count : 1;
-
+    
         var packages = shell.ls(appPackagesFolder);
         expect(packages.filter(function (file) { return 
file.match(fileNamePattern); }).length).toBe(count);
     }
-
+    
     function _expectSubdirAndFileExist (subDirName, fileName, count) {
         count = typeof count !== 'undefined' ? count : 1;
-
+    
         _expectExist(subDirName);
         verifySubDirContainsFile(subDirName, fileName, count);
     }
 
-    beforeEach(function () {
+    var silent = false;
+
+    // create project once
+    beforeAll(function () {
+        // clean up first
+        shell.cd(buildDirectory);
+        shell.rm('-rf', projectTemplateName);
+        shell.rm('-rf', projectFolder);
+
+        // create and prepare project
         shell.exec(path.join('bin', 'create') + ' "' + projectFolder + '" 
com.test.app 応用', {silent: silent});
         shell.exec(prepareScriptPath + '', {silent: silent});
+
+        // create template dir
+        shell.cd(buildDirectory);
+        shell.mkdir(projectTemplateName);
+        // copy project over
+        shell.mv(path.join(projectDirectory, '*'), projectTemplateDirectory);
+
+        // remove generated project (but keep it as template)
+        shell.cd(buildDirectory);
+        shell.rm('-rf', projectFolder);
+        console.log('beforeAll end');
+    });
+
+    // copy project over before each test run
+    beforeEach(function () {
+        console.log('beforeEach');
+        shell.cd(buildDirectory);
+        shell.mkdir(projectFolder);
+        shell.cp('-R', path.join(projectTemplateDirectory, '*'), 
projectDirectory);
     });
 
     afterEach(function () {
@@ -70,6 +99,14 @@ describe('Cordova create and build', function () {
         shell.rm('-rf', projectFolder);
     });
 
+    afterAll(function () {
+        // now also remove the template project
+        shell.cd(buildDirectory);
+        shell.rm('-rf', projectTemplateName);
+    });
+
+    // Tests
+
     it('spec.1 should create new project', function () {
         expect(fs.existsSync(projectFolder)).toBe(true);
     });

-- 
To stop receiving notification emails like this one, please contact
jan...@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to