cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject [05/14] cordova-medic git commit: replacing 'windows8' platform with 'windows'
Date Thu, 13 Nov 2014 05:24:45 GMT
replacing 'windows8' platform with 'windows'


Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/2cde8c0a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/2cde8c0a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/2cde8c0a

Branch: refs/heads/master
Commit: 2cde8c0ab47fe3e99d0f8115598ecf31ad64470a
Parents: 23d1cd5
Author: MariaBukharina <maria.bukharina@akvelon.com>
Authored: Wed Oct 8 16:18:12 2014 +0400
Committer: MariaBukharina <maria.bukharina@akvelon.com>
Committed: Wed Oct 8 16:18:12 2014 +0400

----------------------------------------------------------------------
 build_windows.js             |  70 ++++++++++++++++++++++++
 build_windows8.js            |  74 --------------------------
 master.cfg                   |  28 ++++------
 repos.json                   |   8 +--
 src/build/makers/windows.js  | 109 ++++++++++++++++++++++++++++++++++++++
 src/build/makers/windows8.js | 109 --------------------------------------
 6 files changed, 192 insertions(+), 206 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/2cde8c0a/build_windows.js
----------------------------------------------------------------------
diff --git a/build_windows.js b/build_windows.js
new file mode 100644
index 0000000..6f3cb55
--- /dev/null
+++ b/build_windows.js
@@ -0,0 +1,70 @@
+var fs = require('fs');
+var path = require ('path');
+var shell = require('shelljs');
+var buildinfo = require('./buildinfo');
+var config = require('./config');
+var windows  = require('./src/build/makers/windows');
+var argv = require('optimist').argv;
+var error_writer = require('./src/build/makers/error_writer');
+
+// this assumes that you start it in the sandbox
+
+var TEST_DIR=process.cwd().replace(/\\/g, '\\\\');
+var BRANCH='master';
+var TOOL_DIR=path.join(TEST_DIR,'medic');
+var MSPEC_DIR=path.join(TEST_DIR,'mobilespec');
+
+var TEST_OK=true;
+
+if(argv.branch) BRANCH=argv.branch;
+
+var output_location = path.join(MSPEC_DIR,'platforms','windows');
+
+buildinfo('Windows', BRANCH, function (error, sha ) {
+
+    function log(msg) {
+        console.log('[WINDOWS] ' + msg + ' (sha: ' + sha + ')');
+    }
+
+    function setTargetStoreVersion(version) {
+        log('setting target store version to ' + version);
+
+        var configPath = 'mobilespec/config.xml';
+        configContent = fs.readFileSync(configPath, "utf8");
+
+        var versionPreference = '<preference name="windows-target-version" value="' +
version + '" />';
+        configContent = configContent.replace ('</widget>', versionPreference + '\r\n</widget>')
+
+        fs.writeFileSync(configPath, configContent, "utf8");
+    }
+
+    if(error) {
+        TEST_OK=false;
+    } else {
+        // timeout to execute tests, 10 min by default
+        var test_timeout = config.app.timeout ? config.app.timeout : 10 * 60;
+        log(argv);
+        var build_target = argv.phone ? "phone" : argv.store80 ? "store80" : "store";
+        log(build_target);
+
+        if (build_target == "store80") {
+            build_target == "store";
+            //setTargetStoreVersion('8.0'); // this value is used by default
+        } else if (build_target == "store") {
+            // store target configuration is specified via config.xml 
+            setTargetStoreVersion('8.1');
+        }
+
+        windows(output_location, sha, config.app.entry, config.couchdb.host, test_timeout,
build_target).then(function() {
+                console.log('Windows test execution completed');
+            }, function(err) {
+                TEST_OK=false;
+                error_writer('windows', sha, 'Windows tests execution failed.', err);
+            });
+    }
+});
+
+process.once('exit', function () {
+    if(!TEST_OK) process.exit(1);
+});
+

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/2cde8c0a/build_windows8.js
----------------------------------------------------------------------
diff --git a/build_windows8.js b/build_windows8.js
deleted file mode 100644
index b7bb821..0000000
--- a/build_windows8.js
+++ /dev/null
@@ -1,74 +0,0 @@
-var fs = require('fs');
-var path = require ('path');
-var shell = require('shelljs');
-var buildinfo = require('./buildinfo');
-var config = require('./config');
-var windows8  = require('./src/build/makers/windows8');
-var argv = require('optimist').argv;
-var error_writer = require('./src/build/makers/error_writer');
-
-// this assumes that you start it in the sandbox
-
-var TEST_DIR=process.cwd().replace(/\\/g, '\\\\');
-var BRANCH='master';
-var TOOL_DIR=path.join(TEST_DIR,'medic');
-var MSPEC_DIR=path.join(TEST_DIR,'mobilespec');
-
-var TEST_OK=true;
-
-if(argv.branch) BRANCH=argv.branch;
-
-var output_location = path.join(MSPEC_DIR,'platforms','windows8');
-// fixes tests crash when windows universal apps used to test
-if (!fs.existsSync(output_location)){
-    output_location = path.join(MSPEC_DIR,'platforms','windows');
-}
-
-buildinfo('Windows8', BRANCH, function (error, sha ) {
-
-    function log(msg) {
-        console.log('[WINDOWS8] ' + msg + ' (sha: ' + sha + ')');
-    }
-
-    function setTargetStoreVersion(version) {
-        log('setting target store version to ' + version);
-
-        var configPath = 'mobilespec/config.xml';
-        configContent = fs.readFileSync(configPath, "utf8");
-
-        var versionPreference = '<preference name="windows-target-version" value="' +
version + '" />';
-        configContent = configContent.replace ('</widget>', versionPreference + '\r\n</widget>')
-
-        fs.writeFileSync(configPath, configContent, "utf8");
-    }
-
-    if(error) {
-        TEST_OK=false;
-    } else {
-        // timeout to execute tests, 10 min by default
-        var test_timeout = config.app.timeout ? config.app.timeout : 10 * 60;
-        log(argv);
-        var build_target = argv.phone ? "phone" : argv.store80 ? "store80" : "store";
-        log(build_target);
-
-        if (build_target == "store80") {
-            build_target == "store";
-            //setTargetStoreVersion('8.0'); // this value is used by default
-        } else if (build_target == "store") {
-            // store target configuration is specified via config.xml 
-            setTargetStoreVersion('8.1');
-        }
-
-        windows8(output_location, sha, config.app.entry, config.couchdb.host, test_timeout,
build_target).then(function() {
-                console.log('Windows8 test execution completed');
-            }, function(err) {
-                TEST_OK=false;
-                error_writer('windows8', sha, 'Windows8 tests execution failed.', err);
-            });
-    }
-});
-
-process.once('exit', function () {
-    if(!TEST_OK) process.exit(1);
-});
-

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/2cde8c0a/master.cfg
----------------------------------------------------------------------
diff --git a/master.cfg b/master.cfg
index 7b72ece..daa6488 100644
--- a/master.cfg
+++ b/master.cfg
@@ -40,7 +40,7 @@ build_android = ('android' in platform_list)
 build_chrome = ('chrome' in platform_list)
 build_ios = ('ios' in platform_list)
 build_wp8 = ('wp8' in platform_list)
-build_windows8 = ('windows8' in platform_list)
+build_windows = ('windows' in platform_list)
 build_blackberry = ('blackberry' in platform_list)
 projectbranches = ['master', branch_release]
 polltime = 300
@@ -119,7 +119,7 @@ for jrepo in json_repos['repos']:
         if (build_android and title == "ANDROID"
             or build_ios and title == "IOS"
             or build_wp8 and title == "WP8"
-            or build_windows8 and title == "WINDOWS8"
+            or build_windows and title == "WINDOWS"
             or build_blackberry and title == "BLACKBERRY"):
 
             listen_for_source_change(repo_url, title, 'PLATFORM', getBranches([jrepo['release'],
jrepo['current']]))
@@ -211,8 +211,6 @@ class PlatformTestBase(object):
         # required by coho tools to correctly resolve repo location
         if platform == "blackberry10":
             platform = "blackberry"
-        if platform == "windows8":
-            platform = "windows"
         if platform == "wp8":
             platform = "windowsphone"
         return [
@@ -234,8 +232,6 @@ class PlatformTestBase(object):
         # required by coho tools to correctly resolve repo location
         if platform == "blackberry10":
             platform = "blackberry"
-        if platform == "windows8":
-            platform = "windows"
         platformPath = "../cordova-" + platform
         return [ShellCommand(command=["../cordova-cli/bin/cordova", "platform", "add", platformPath],
workdir='build/mobilespec', haltOnFailure=True, description='Platform Add')]
 
@@ -314,16 +310,10 @@ class PlatformTest_WP8(PlatformTestBase):
         return steps
 
 
-class PlatformTest_Windows8(PlatformTestBase):
+class PlatformTest_Windows(PlatformTestBase):
 
     def __init__(self):
-        super(PlatformTest_Windows8, self).__init__('windows8')
-
-    def copy_cordovajs_steps(self):
-        copy_cmd = "var fs=require('fs');"
-        copy_cmd += "var platform=fs.existsSync('mobilespec/platforms/windows8')?'windows8':'windows';"
-        copy_cmd += "fs.createReadStream('cordova-js/pkg/cordova.'+platform+'.js').pipe(fs.createWriteStream('mobilespec/platforms/'+platform+'/platform_www/cordova.js'));"
-        return [ShellCommand(command=["node", "-e", copy_cmd], workdir='build', haltOnFailure=False,
description='Copy JS to Windows platform')]
+        super(PlatformTest_Windows, self).__init__('windows')
 
     def deploy_steps(self):
         return [
@@ -377,11 +367,11 @@ if(build_wp8):
     c['builders'].append(BuilderConfig(name="WP8", slavenames=["windows-slave"], factory=factory_wp8))
     c['builders'].append(BuilderConfig(name="WP8_vs2012_win8", slavenames=["win8-slave"],
factory=factory_wp8))
 
-if(build_windows8):
-    factory_windows8 = BuildFactory()
-    factory_windows8.addSteps(PlatformTest_Windows8().get_all_steps())
-    c['builders'].append(BuilderConfig(name="Windows8", slavenames=["windows-slave"], factory=factory_windows8))
-    c['builders'].append(BuilderConfig(name="Windows8_vs2012_win8", slavenames=["win8-slave"],
factory=factory_windows8))
+if(build_windows):
+    factory_windows = BuildFactory()
+    factory_windows.addSteps(PlatformTest_Windows().get_all_steps())
+    c['builders'].append(BuilderConfig(name="Windows", slavenames=["windows-slave"], factory=factory_windows))
+    c['builders'].append(BuilderConfig(name="Windows8_vs2012_win8", slavenames=["win8-slave"],
factory=factory_windows))
 
 if(build_blackberry):
     factory_BlackBerry = BuildFactory()

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/2cde8c0a/repos.json
----------------------------------------------------------------------
diff --git a/repos.json b/repos.json
index 6df6f94..ca7cf0e 100644
--- a/repos.json
+++ b/repos.json
@@ -45,10 +45,10 @@
   },
   {
     "title" : "Windows 8 master",
-    "categories" : ["WINDOWS8"],
+    "categories" : ["WINDOWS"],
     "branch" : "master",
-    "builder": ["Windows8", "Windows8_vs2012_win8"],
-    "platform": "windows8"
+    "builder": ["Windows", "Windows8_vs2012_win8"],
+    "platform": "windows"
   }
 ,
   {
@@ -153,7 +153,7 @@
     "release" : "master",
     "current" :"master"
 },{
-    "title" : "WINDOWS8",
+    "title" : "WINDOWS",
     "repo"  : "https://git-wip-us.apache.org/repos/asf/cordova-windows.git",
     "category" : "PLATFORM",
     "release" : "master",

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/2cde8c0a/src/build/makers/windows.js
----------------------------------------------------------------------
diff --git a/src/build/makers/windows.js b/src/build/makers/windows.js
new file mode 100644
index 0000000..ddedd93
--- /dev/null
+++ b/src/build/makers/windows.js
@@ -0,0 +1,109 @@
+var shell        = require('shelljs'),
+    path         = require('path'),
+    n            = require('ncallbacks'),
+    fs           = require('fs'),
+    mspec        = require('./mobile_spec'),
+    couch        = require('../../couchdb/interface'),
+    q            = require('q'),
+    testRunner   = require('./testRunner'),
+    util         = require('util');
+
+module.exports = function(output, sha, entry_point, couchdb_host, test_timeout, build_target)
{
+
+    function run() {
+        var d = q.defer();
+        log('Running app...');       
+        var cmd = (build_target == "store80" || build_target == "phone") ?
+            '..\\cordova-cli\\bin\\cordova.cmd run -- --' + build_target :
+            '..\\cordova-cli\\bin\\cordova.cmd run',
+            logFile = sha + '.log',
+            errFile = sha + '.err',
+            endFile = sha + '.end',
+            runner = 'run.bat';
+
+        // create commands that should be started from bat file:
+        //  1. cd to project folder
+        //  2. start 'cmd' defined earlier and redirect its stdout and stderr to files
+        //  3. print exit code of 'cmd' to 'endfile'
+        var runnerContent = util.format('cd /d "%s"\n%s 1>%s 2>%s & echo "%ERRORLEVEL%"
>%s',
+            shell.pwd(), cmd, logFile, errFile, endFile);
+        
+        fs.writeFileSync(runner, runnerContent, 'utf-8');
+
+        // the following hack with explorer.exe usage is required to start the tool w/o Admin
privileges;
+        // in other case there will be the 'app can't open while File Explorer is running
with administrator privileges ...' error
+        shell.exec('explorer ' + runner, {async: false});
+
+        // Due to explorer, that don't redirects output of child cmd process
+        // and exits immediately after starting bat file we are waiting for
+        // special marker - 'endfile' - to be created when cordova run exits.
+        var waitForRunner = setInterval(function () {
+            if (fs.existsSync(endFile)){
+                clearInterval(waitForRunner);
+                log(fs.readFileSync(logFile));
+                // read 'cordova run' exit code from endfile, that was written by run.bat
+                var exitCode = parseInt(fs.readFileSync(endFile, 'utf-8'), 10);
+                if (exitCode > 0){
+                    log(fs.readFileSync(errFile));
+                    d.reject('Unable to run application. Exit code: ' + exitCode);
+                }
+                d.resolve();
+            }
+        }, 1000);
+        return d.promise;
+    }
+
+    function log(msg) {
+        console.log('[WINDOWS] ' + msg + ' (sha: ' + sha + ')');
+    }
+
+    function prepareMobileSpec() {
+        // make sure windows app got created first.
+        var defer = q.defer();
+        try {
+            if (!fs.existsSync(output)) {
+                throw new Error('create must have failed as output path does not exist.');
+            }
+            var mspec_out = path.join(output, 'www');
+
+            log('Modifying Cordova Mobilespec application at:'+mspec_out);
+
+            mspec(mspec_out,sha,'',entry_point, function(err){
+                if(err) {
+                    throw new Error('Error while modifying Windows mobile spec application.');
+                }
+
+                // specify couchdb server and sha for cordova medic plugin via medic.json
+                log('Write medic.json to autotest folder');
+                var medic_config='{"sha":"'+sha+'","couchdb":"'+couchdb_host+'"}';
+                fs.writeFileSync(path.join(output, '..', '..', 'www','autotest','pages',
'medic.json'),medic_config,'utf-8');
+                
+                // patch WindowsStoreAppUtils script to allow app run w/out active desktop/remote
session
+                if (build_target == "store80" || build_target == "store") {
+                    log('Patching WindowsStoreAppUtils to allow app to be run in automated
mode');
+                    shell.cp('-f', path.join(output, '..', '..', '..','medic','src', 'utils',
'EnableDebuggingForPackage.ps1'),
+                             path.join(output, 'cordova', 'lib'));
+                    shell.sed('-i', /^\s*\$appActivator .*$/gim,
+                              '$&\n' +
+                              '    powershell ' + path.join(output, 'cordova', 'lib', 'EnableDebuggingForPackage.ps1')
+ ' $$ID\n' +
+                              '    $Ole32 = Add-Type -MemberDefinition \'[DllImport("Ole32.dll")]public
static extern int CoAllowSetForegroundWindow(IntPtr pUnk, IntPtr lpvReserved);\' -Name \'Ole32\'
-Namespace \'Win32\' -PassThru\n' +
+                              '    $Ole32::CoAllowSetForegroundWindow([System.Runtime.InteropServices.Marshal]::GetIUnknownForObject($appActivator),
[System.IntPtr]::Zero)',
+                              path.join(output, 'cordova', 'lib', 'WindowsStoreAppUtils.ps1'));
+                }
+
+                defer.resolve();
+            });
+        }
+        catch (e) {
+            defer.reject(e);
+        }
+        return defer.promise;
+    }
+
+    return prepareMobileSpec().then(function() {
+            shell.cd(path.join(output, '..', '..'));
+            return run();
+        }).then(function() {
+            return testRunner.waitTestsCompleted(sha, 1000 * test_timeout);
+        });
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/2cde8c0a/src/build/makers/windows8.js
----------------------------------------------------------------------
diff --git a/src/build/makers/windows8.js b/src/build/makers/windows8.js
deleted file mode 100644
index 0fe2553..0000000
--- a/src/build/makers/windows8.js
+++ /dev/null
@@ -1,109 +0,0 @@
-var shell        = require('shelljs'),
-    path         = require('path'),
-    n            = require('ncallbacks'),
-    fs           = require('fs'),
-    mspec        = require('./mobile_spec'),
-    couch        = require('../../couchdb/interface'),
-    q            = require('q'),
-    testRunner   = require('./testRunner'),
-    util         = require('util');
-
-module.exports = function(output, sha, entry_point, couchdb_host, test_timeout, build_target)
{
-
-    function run() {
-        var d = q.defer();
-        log('Running app...');       
-        var cmd = (build_target == "store80" || build_target == "phone") ?
-            '..\\cordova-cli\\bin\\cordova.cmd run -- --' + build_target :
-            '..\\cordova-cli\\bin\\cordova.cmd run',
-            logFile = sha + '.log',
-            errFile = sha + '.err',
-            endFile = sha + '.end',
-            runner = 'run.bat';
-
-        // create commands that should be started from bat file:
-        //  1. cd to project folder
-        //  2. start 'cmd' defined earlier and redirect its stdout and stderr to files
-        //  3. print exit code of 'cmd' to 'endfile'
-        var runnerContent = util.format('cd /d "%s"\n%s 1>%s 2>%s & echo "%ERRORLEVEL%"
>%s',
-            shell.pwd(), cmd, logFile, errFile, endFile);
-        
-        fs.writeFileSync(runner, runnerContent, 'utf-8');
-
-        // the following hack with explorer.exe usage is required to start the tool w/o Admin
privileges;
-        // in other case there will be the 'app can't open while File Explorer is running
with administrator privileges ...' error
-        shell.exec('explorer ' + runner, {async: false});
-
-        // Due to explorer, that don't redirects output of child cmd process
-        // and exits immediately after starting bat file we are waiting for
-        // special marker - 'endfile' - to be created when cordova run exits.
-        var waitForRunner = setInterval(function () {
-            if (fs.existsSync(endFile)){
-                clearInterval(waitForRunner);
-                log(fs.readFileSync(logFile));
-                // read 'cordova run' exit code from endfile, that was written by run.bat
-                var exitCode = parseInt(fs.readFileSync(endFile, 'utf-8'), 10);
-                if (exitCode > 0){
-                    log(fs.readFileSync(errFile));
-                    d.reject('Unable to run application. Exit code: ' + exitCode);
-                }
-                d.resolve();
-            }
-        }, 1000);
-        return d.promise;
-    }
-
-    function log(msg) {
-        console.log('[WINDOWS8] ' + msg + ' (sha: ' + sha + ')');
-    }
-
-    function prepareMobileSpec() {
-        // make sure windows8 app got created first.
-        var defer = q.defer();
-        try {
-            if (!fs.existsSync(output)) {
-                throw new Error('create must have failed as output path does not exist.');
-            }
-            var mspec_out = path.join(output, 'www');
-
-            log('Modifying Cordova Mobilespec application at:'+mspec_out);
-
-            mspec(mspec_out,sha,'',entry_point, function(err){
-                if(err) {
-                    throw new Error('Error while modifying Windows8 mobile spec application.');
-                }
-
-                // specify couchdb server and sha for cordova medic plugin via medic.json
-                log('Write medic.json to autotest folder');
-                var medic_config='{"sha":"'+sha+'","couchdb":"'+couchdb_host+'"}';
-                fs.writeFileSync(path.join(output, '..', '..', 'www','autotest','pages',
'medic.json'),medic_config,'utf-8');
-                
-                // patch WindowsStoreAppUtils script to allow app run w/out active desktop/remote
session
-                if (build_target == "store80" || build_target == "store") {
-                    log('Patching WindowsStoreAppUtils to allow app to be run in automated
mode');
-                    shell.cp('-f', path.join(output, '..', '..', '..','medic','src', 'utils',
'EnableDebuggingForPackage.ps1'),
-                             path.join(output, 'cordova', 'lib'));
-                    shell.sed('-i', /^\s*\$appActivator .*$/gim,
-                              '$&\n' +
-                              '    powershell ' + path.join(output, 'cordova', 'lib', 'EnableDebuggingForPackage.ps1')
+ ' $$ID\n' +
-                              '    $Ole32 = Add-Type -MemberDefinition \'[DllImport("Ole32.dll")]public
static extern int CoAllowSetForegroundWindow(IntPtr pUnk, IntPtr lpvReserved);\' -Name \'Ole32\'
-Namespace \'Win32\' -PassThru\n' +
-                              '    $Ole32::CoAllowSetForegroundWindow([System.Runtime.InteropServices.Marshal]::GetIUnknownForObject($appActivator),
[System.IntPtr]::Zero)',
-                              path.join(output, 'cordova', 'lib', 'WindowsStoreAppUtils.ps1'));
-                }
-
-                defer.resolve();
-            });
-        }
-        catch (e) {
-            defer.reject(e);
-        }
-        return defer.promise;
-    }
-
-    return prepareMobileSpec().then(function() {
-            shell.cd(path.join(output, '..', '..'));
-            return run();
-        }).then(function() {
-            return testRunner.waitTestsCompleted(sha, 1000 * test_timeout);
-        });
-};
\ No newline at end of file


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


Mime
View raw message