cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [1/10] git commit: using cli tools, bootstrap now creates a project for use as text fixtures on install. bootstrap now uses the check_requirements function for platform-specific req checks on install as well. removed old cordova project fixture that was
Date Thu, 31 Jan 2013 22:03:46 GMT
using cli tools, bootstrap now creates a project for use as text fixtures on install. bootstrap
now uses the check_requirements function for platform-specific req checks on install as well.
removed old cordova project fixture that was "manually" added.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/5ef109bd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/5ef109bd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/5ef109bd

Branch: refs/heads/master
Commit: 5ef109bd60148de11b8b6330d39066542262ca88
Parents: ff34f5d
Author: Fil Maj <maj.fil@gmail.com>
Authored: Mon Jan 28 20:54:23 2013 -0800
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Mon Jan 28 20:54:23 2013 -0800

----------------------------------------------------------------------
 .gitignore                                 |    3 +-
 bootstrap.js                               |   53 +++++-
 spec/cli.spec.js                           |  226 -----------------------
 spec/cordova.spec.js                       |  195 -------------------
 spec/fixtures/projects/test/.cordova       |    1 -
 spec/fixtures/projects/test/www/config.xml |    5 -
 spec/metadata/android_parser.spec.js       |  134 +++++++-------
 src/metadata/android_parser.js             |    2 +-
 8 files changed, 115 insertions(+), 504 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index a690a1c..7bf8a35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@ npm-debug.log
 temp
 .DS_Store
 spec/fixtures/projects/native
-lib/**
+spec/fixtures/projects/cordova
+lib

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/bootstrap.js
----------------------------------------------------------------------
diff --git a/bootstrap.js b/bootstrap.js
index 6e18e85..87baff8 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -21,22 +21,57 @@
  **/
 
 var util      = require('./src/util'),
+    create    = require('./src/create'),
+    a_parser  = require('./src/metadata/android_parser'),
+    b_parser  = require('./src/metadata/blackberry_parser'),
+    i_parser  = require('./src/metadata/ios_parser'),
     path      = require('path'),
     shell     = require('shelljs'),
     platforms = require('./platforms');
 
+// Library requirements checkers
+var min_reqs = {
+    "android":a_parser.check_requirements,
+    "ios":i_parser.check_requirements,
+    "blackberry":b_parser.check_requirements
+}
+
 // Create native projects using bin/create
-var tempDir = path.join(__dirname, 'spec', 'fixtures', 'projects', 'native');
+var projectFixtures = path.join(__dirname, 'spec', 'fixtures', 'projects');
+var tempDir = path.join(projectFixtures, 'native');
 shell.rm('-rf', tempDir);
 shell.mkdir('-p', tempDir);
 
+// Also create a standard cordova project for tests
+var cordovaDir = path.join(projectFixtures, 'cordova');
+shell.rm('-rf', cordovaDir);
+create(cordovaDir);
+var platformsDir = path.join(cordovaDir, 'platforms');
+
 platforms.forEach(function(platform) {
-    var fix_path = path.join(tempDir, platform + '_fixture');
-    var create = path.join(util.libDirectory, 'cordova-' + platform, 'bin', 'create'); 
-    console.log('Creating cordova-' + platform + ' project using live project lib for tests...');
-    var cmd = create + ' "' + fix_path + '" org.apache.cordova.cordovaExample cordovaExample';
-    if (platform == 'blackberry') cmd = create + ' "' + fix_path + '" cordovaExample';
-    var create_result = shell.exec(cmd, {silent:true});
-    if (create_result.code > 0) throw ('Could not create a native ' + platform + ' project
test fixture: ' + create_result.output);
-    console.log('.. complete.');
+    min_reqs[platform](function(err) {
+        if (err) {
+            console.error('WARNING: Your system does not meet requirements to create ' +
platform + 'projects. See error output below.');
+            console.error(err);
+            console.error('SKIPPING ' + platform + ' bootstrap.');
+        } else {
+            console.log('SUCCESS: Minimum requirements for ' + platform + ' met.');
+            var fix_path = path.join(tempDir, platform + '_fixture');
+            var create = path.join(util.libDirectory, 'cordova-' + platform, 'bin', 'create');

+            console.log('BOOTSTRAPPING ' + platform + '...');
+            var cmd = create + ' "' + fix_path + '" org.apache.cordova.cordovaExample cordovaExample';
+            if (platform == 'blackberry') cmd = create + ' "' + fix_path + '" cordovaExample';
+            shell.exec(cmd, {silent:true, async:true}, function(code, output) {
+                if (code > 0) {
+                    console.error('ERROR! Could not create a native ' + platform + ' project
test fixture. See below for error output.');
+                    console.error(output);
+                } else {
+                    var platformDir = path.join(platformsDir, platform);
+                    shell.mkdir('-p', platformDir);
+                    shell.cp('-rf', path.join(fix_path, '*'), platformDir); 
+                    console.log('SUCCESS: ' + platform + ' ready to rock!');
+                }
+            });
+        }
+    });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/spec/cli.spec.js
----------------------------------------------------------------------
diff --git a/spec/cli.spec.js b/spec/cli.spec.js
deleted file mode 100644
index 70b8777..0000000
--- a/spec/cli.spec.js
+++ /dev/null
@@ -1,226 +0,0 @@
-
-/**
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-var shell = require('shelljs'),
-    path = require('path'),
-    fs = require('fs'),
-    cordova = require('../cordova'),
-    tempDir = path.join(__dirname, '..', 'temp'),
-    plugins = path.join(__dirname, 'fixtures', 'plugins'),
-    androidPlugin = path.join(plugins, 'android'),
-    testPlugin = path.join(plugins, 'test'),
-    bin = path.join(__dirname, '..', 'bin', 'cordova');
-
-var cwd = process.cwd();
-
-describe('cli interface', function() {
-    beforeEach(function() {
-        shell.rm('-rf', tempDir);
-    });
-    afterEach(function() {
-        shell.rm('-rf', tempDir);
-    });
-
-    it('should print out version with -v', function() {
-        var cmd = bin + ' -v';
-        var output = shell.exec(cmd, {silent:true}).output;
-        expect(output.indexOf(require('../package').version)).toBe(0);
-    });
-    
-    describe('create', function() {
-        it('should create a project when only dir is specified', function() {
-            var cmd = bin + ' create ' + tempDir;
-            var result = shell.exec(cmd, {silent:true});
-            expect(result.code).toEqual(0);
-            expect(fs.existsSync(path.join(tempDir, '.cordova'))).toBe(true);
-        });
-        it('should create a project when dir + name are specified', function() {
-            var cmd = bin + ' create ' + tempDir + ' foobar';
-            var result = shell.exec(cmd, {silent:true});
-            expect(result.code).toEqual(0);
-            expect(fs.existsSync(path.join(tempDir, '.cordova'))).toBe(true);
-            expect(fs.readFileSync(path.join(tempDir, 'www', 'config.xml'), 'utf-8')).toMatch(/<name>foobar/i);
-        });
-        it('should create a project when all parameters are specified', function() {
-            var cmd = bin + ' create ' + tempDir + ' ca.filmaj.foobar foobar';
-            var result = shell.exec(cmd, {silent:true});
-            expect(result.code).toEqual(0);
-            expect(fs.existsSync(path.join(tempDir, '.cordova'))).toBe(true);
-            var config = fs.readFileSync(path.join(tempDir, 'www', 'config.xml'), 'utf-8');
-            expect(config).toMatch(/<name>foobar/i);
-            expect(config).toMatch(/id="ca.filmaj.foobar"/i);
-        });
-    });
-
-    describe('help', function() {
-        it('should print out docs as default command', function() {
-            var result = shell.exec(bin, {silent:true});
-            expect(result.code).toEqual(0);
-            expect(result.output).toMatch(new RegExp(fs.readFileSync(path.join(__dirname,
'..', 'doc', 'help.txt'), 'utf-8').split('\n')[0]));
-        });
-        it('should print out docs when explicitly specified', function() {
-            var result = shell.exec(bin + ' help', {silent:true});
-            expect(result.code).toEqual(0);
-            expect(result.output).toMatch(new RegExp(fs.readFileSync(path.join(__dirname,
'..', 'doc', 'help.txt'), 'utf-8').split('\n')[0]));
-        });
-    });
-
-    describe('platform', function() {
-        beforeEach(function() {
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-        });
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-        describe('add', function() {
-            it('should be able to add multiple platforms from a single invocation', function()
{
-                var cmd = bin + ' platform add android ios';
-                var result = shell.exec(cmd, {silent:true});
-                expect(result.code).toEqual(0);
-                var platforms = fs.readdirSync(path.join(tempDir, 'platforms'));
-                expect(platforms.length).toEqual(2);
-                expect(platforms.indexOf('ios') > -1).toBe(true);
-                expect(platforms.indexOf('android') > -1).toBe(true);
-            });
-            it('should be able to add a single platform', function() {
-                var cmd = bin + ' platform add android';
-                var result = shell.exec(cmd, {silent:true});
-                expect(result.code).toEqual(0);
-                var platforms = fs.readdirSync(path.join(tempDir, 'platforms'));
-                expect(platforms.length).toEqual(1);
-                expect(platforms.indexOf('android') > -1).toBe(true);
-            });
-        });
-        describe('remove', function() {
-            beforeEach(function() {
-                cordova.platform('add', 'android');
-            });
-            it('should be able to remove multiple platforms from a single invocation', function()
{
-                var cb = jasmine.createSpy();
-                runs(function() {
-                    cordova.platform('add', 'ios', cb);
-                });
-                waitsFor(function() { return cb.wasCalled; }, 'add ios');
-                runs(function() {
-                    var result = shell.exec(bin + ' platform rm ios android', {silent:true});
-                    expect(result.code).toEqual(0);
-                    expect(fs.readdirSync(path.join(tempDir, 'platforms')).length).toEqual(0);
-                });
-            });
-            it('should be able to remove a single platform', function() {
-                var result = shell.exec(bin + ' platform rm android', {silent:true});
-                expect(result.code).toEqual(0);
-                expect(fs.readdirSync(path.join(tempDir, 'platforms')).length).toEqual(0);
-            });
-        });
-        describe('ls', function() {
-            beforeEach(function() {
-                cordova.platform('add', 'android');
-            });
-            it('should be able to list platforms with no sub-command specified', function()
{
-                var result = shell.exec(bin + ' platform', {silent:true});
-                expect(result.code).toEqual(0);
-                expect(result.output).toMatch(/android/);
-            });
-            it('should be able to list platforms with sub-command specified', function()
{
-                var result = shell.exec(bin + ' platform ls', {silent:true});
-                expect(result.code).toEqual(0);
-                expect(result.output).toMatch(/android/);
-            });
-        });
-    });
-
-    describe('plugin', function() {
-        beforeEach(function() {
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-            cordova.platform('add', 'android');
-        });
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-        describe('add', function() {
-            it('should be able to add multiple plugins from a single invocation', function()
{
-                var cmd = bin + ' plugin add ' + testPlugin + ' ' + androidPlugin;
-                var result = shell.exec(cmd, {silent:true});
-                expect(result.code).toEqual(0);
-                var addedPlugins = fs.readdirSync(path.join(tempDir, 'plugins'));
-                expect(addedPlugins.length).toEqual(2);
-                expect(addedPlugins.indexOf('android') > -1).toBe(true);
-                expect(addedPlugins.indexOf('test') > -1).toBe(true);
-            });
-            it('should be able to add a single plugin', function() {
-                var cmd = bin + ' plugin add ' + testPlugin;
-                var result = shell.exec(cmd, {silent:true});
-                expect(result.code).toEqual(0);
-                var addedPlugins = fs.readdirSync(path.join(tempDir, 'plugins'));
-                expect(addedPlugins.length).toEqual(1);
-                expect(addedPlugins.indexOf('test') > -1).toBe(true);
-            });
-        });
-        describe('remove', function() {
-            beforeEach(function() {
-                cordova.plugin('add', [testPlugin, androidPlugin]);
-            });
-            it('should be able to remove multiple plugins from a single invocation', function()
{
-                var cmd = bin + ' plugin rm test android';
-                var result = shell.exec(cmd, {silent:true});
-                expect(result.code).toEqual(0);
-                var addedPlugins = fs.readdirSync(path.join(tempDir, 'plugins'));
-                expect(addedPlugins.length).toEqual(0);
-            });
-            it('should be able to remove a single plugin', function() {
-                var cmd = bin + ' plugin rm test';
-                var result = shell.exec(cmd, {silent:true});
-                expect(result.code).toEqual(0);
-                var addedPlugins = fs.readdirSync(path.join(tempDir, 'plugins'));
-                expect(addedPlugins.length).toEqual(1);
-                expect(addedPlugins.indexOf('android') > -1).toBe(true);
-            });
-        });
-        describe('ls', function() {
-            beforeEach(function() {
-                cordova.plugin('add', androidPlugin);
-            });
-            it('should be able to list plugins with no sub-command specified', function()
{
-                var result = shell.exec(bin + ' plugin', {silent:true});
-                expect(result.code).toEqual(0);
-                expect(result.output).toMatch(/android/);
-            });
-            it('should be able to list plugins with sub-command specified', function() {
-                var result = shell.exec(bin + ' plugin list', {silent:true});
-                expect(result.code).toEqual(0);
-                expect(result.output).toMatch(/android/);
-            });
-        });
-    });
-
-    describe('build', function() {
-        xit('should be able to build all platforms when none are specified');
-        xit('should be able to build a specific single platform');
-        xit('should be able to build multiple, specific platforms from a single invocation');
-    });
-
-    describe('emulate', function() {
-        xit('should be able to emulate all platforms when none are specified');
-        xit('should be able to emulate a specific single platform');
-        xit('should be able to emulate multiple, specific platforms from a single invocation');
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/spec/cordova.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova.spec.js b/spec/cordova.spec.js
deleted file mode 100644
index c501e21..0000000
--- a/spec/cordova.spec.js
+++ /dev/null
@@ -1,195 +0,0 @@
-
-/**
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-var cordova = require('../cordova'),
-    path = require('path'),
-    shell = require('shelljs'),
-    androidPlugin = path.join(__dirname, 'fixtures', 'plugins', 'android'),
-    tempDir = path.join(__dirname, '..', 'temp');
-
-var cwd = process.cwd();
-
-describe('top-level cordova module', function() {
-    beforeEach(function() {
-        cordova.create(tempDir);
-        process.chdir(tempDir);
-    });
-    afterEach(function() {
-        shell.rm('-rf', tempDir);
-        process.chdir(cwd);
-    });
-
-    describe('hooks/events', function() {
-        describe('for build command', function() {
-            beforeEach(function() {
-                cordova.platform('add', 'android');
-            });
-            it('should fire before_build event', function() {
-                var s = jasmine.createSpy('event listener');
-                cordova.on('before_build', s);
-                spyOn(shell, 'exec').andReturn({code:0});
-                cordova.build();
-                expect(s).toHaveBeenCalled();
-            });
-            it('should fire after_build event', function() {
-                var s = jasmine.createSpy('event listener');
-                cordova.on('after_build', s);
-                spyOn(shell, 'exec').andReturn({code:0});
-                cordova.build();
-                expect(s).toHaveBeenCalled();
-            });
-        });
-        
-        describe('for docs command', function() {
-            // TODO how the f do you spy on express? srsly
-            xit('should fire before_docs event', function() {
-                var s = jasmine.createSpy('event listener');
-                cordova.on('before_docs', s);
-                cordova.docs();
-                expect(s).toHaveBeenCalled();
-            });
-            xit('should fire after_docs event', function() {
-                var s = jasmine.createSpy('event listener');
-                cordova.on('after_docs', s);
-                cordova.docs();
-                expect(s).toHaveBeenCalled();
-            });
-        });
-
-        describe('for emulate command', function() {
-            beforeEach(function() {
-                cordova.platform('add', 'android');
-            });
-            it('should fire before_emulate event', function() {
-                var s = jasmine.createSpy('event listener');
-                cordova.on('before_emulate', s);
-                spyOn(shell, 'exec').andReturn({code:0});
-                cordova.emulate();
-                expect(s).toHaveBeenCalled();
-            });
-            it('should fire after_emulate event', function() {
-                var s = jasmine.createSpy('event listener');
-                cordova.on('after_emulate', s);
-                spyOn(shell, 'exec').andReturn({code:0});
-                cordova.emulate();
-                expect(s).toHaveBeenCalled();
-            });
-        });
-
-        describe('for platform command', function() {
-            describe('`add`', function() {
-                it('should fire before_platform_add event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('before_platform_add', s);
-                    cordova.platform('add', 'android');
-                    expect(s).toHaveBeenCalled();
-                });
-                it('should fire after_platform_add event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('after_platform_add', s);
-                    cordova.platform('add', 'android');
-                    expect(s).toHaveBeenCalled();
-                });
-            });
-            describe('`rm`', function() {
-                beforeEach(function() {
-                    cordova.platform('add', 'android');
-                });
-                it('should fire before_platform_rm event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('before_platform_rm', s);
-                    cordova.platform('rm', 'android');
-                    expect(s).toHaveBeenCalled();
-                });
-                it('should fire after_platform_rm event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('after_platform_rm', s);
-                    cordova.platform('rm', 'android');
-                    expect(s).toHaveBeenCalled();
-                });
-            });
-            describe('`ls`', function() {
-                it('should fire before_platform_ls event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('before_platform_ls', s);
-                    cordova.platform('ls');
-                    expect(s).toHaveBeenCalled();
-                });
-                it('should fire after_platform_ls event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('after_platform_ls', s);
-                    cordova.platform('ls');
-                    expect(s).toHaveBeenCalled();
-                });
-            });
-        });
-
-        describe('for plugin command', function() {
-            describe('`add`', function() {
-                beforeEach(function() {
-                    cordova.platform('add', 'android');
-                });
-                it('should fire before_plugin_add event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('before_plugin_add', s);
-                    cordova.plugin('add', androidPlugin);
-                    expect(s).toHaveBeenCalled();
-                });
-                it('should fire after_plugin_add event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('after_plugin_add', s);
-                    cordova.plugin('add', androidPlugin);
-                    expect(s).toHaveBeenCalled();
-                });
-            });
-            describe('`rm`', function() {
-                beforeEach(function() {
-                    cordova.platform('add', 'android');
-                    cordova.plugin('add', androidPlugin);
-                });
-                it('should fire before_plugin_rm event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('before_plugin_rm', s);
-                    cordova.plugin('rm', 'android');
-                    expect(s).toHaveBeenCalled();
-                });
-                it('should fire after_plugin_rm event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('after_plugin_rm', s);
-                    cordova.plugin('rm', 'android');
-                    expect(s).toHaveBeenCalled();
-                });
-            });
-            describe('`ls`', function() {
-                it('should fire before_plugin_ls event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('before_plugin_ls', s);
-                    cordova.plugin('ls');
-                    expect(s).toHaveBeenCalled();
-                });
-                it('should fire after_plugin_ls event', function() {
-                    var s = jasmine.createSpy('event listener');
-                    cordova.on('after_plugin_ls', s);
-                    cordova.plugin('ls');
-                    expect(s).toHaveBeenCalled();
-                });
-            });
-        });
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/spec/fixtures/projects/test/.cordova
----------------------------------------------------------------------
diff --git a/spec/fixtures/projects/test/.cordova b/spec/fixtures/projects/test/.cordova
deleted file mode 100644
index 44ab66e..0000000
--- a/spec/fixtures/projects/test/.cordova
+++ /dev/null
@@ -1 +0,0 @@
-{"name":"test","id":"org.apache.cordova","platforms":["android", "ios"]}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/spec/fixtures/projects/test/www/config.xml
----------------------------------------------------------------------
diff --git a/spec/fixtures/projects/test/www/config.xml b/spec/fixtures/projects/test/www/config.xml
deleted file mode 100644
index cfb59fc..0000000
--- a/spec/fixtures/projects/test/www/config.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<widget id="ca.filmaj.dewd" version="2.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
-    <name>bond. james bond.</name>
-    <access origin="*" />
-</widget>

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/spec/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/android_parser.spec.js b/spec/metadata/android_parser.spec.js
index 0fdf881..61eedc1 100644
--- a/spec/metadata/android_parser.spec.js
+++ b/spec/metadata/android_parser.spec.js
@@ -26,45 +26,46 @@ var android_parser = require('../../src/metadata/android_parser'),
     et = require('elementtree'),
     tempDir = path.join(__dirname, '..', '..', 'temp'),
     cordova = require('../../cordova');
-    cfg_path = path.join(__dirname, '..', 'fixtures', 'projects', 'test', 'www', 'config.xml'),
-    android_path = path.join(__dirname, '..', 'fixtures', 'projects', 'native', 'android_fixture'),
-    create = path.join(__dirname, '..', '..', 'lib', 'android', 'bin', 'create');
+    projects_path = path.join(__dirname, '..', 'fixtures', 'projects')
+    android_path = path.join(projects_path, 'native', 'android_fixture'),
+    project_path = path.join(projects_path, 'cordova'),
+    android_project_path = path.join(project_path, 'platforms', 'android');
 
-var cwd = process.cwd();
-
-var android_strings = path.join(android_path, 'res', 'values', 'strings.xml');
-var android_manifest = path.join(android_path, 'AndroidManifest.xml');
-var android_config = path.join(android_path, 'res', 'xml', 'config.xml');
-var original_strings = fs.readFileSync(android_strings, 'utf-8');
-var original_manifest = fs.readFileSync(android_manifest, 'utf-8');
-var original_config = fs.readFileSync(cfg_path, 'utf-8');
-var original_android_config = fs.readFileSync(android_config, 'utf-8');
+var www_config = path.join(project_path, 'www', 'config.xml');
+var original_www_config = fs.readFileSync(www_config, 'utf-8');
 
 describe('android project parser', function() {
     it('should throw an exception with a path that is not a native android project', function()
{
         expect(function() {
-            var project = new android_parser(cwd);
+            var project = new android_parser(process.cwd());
         }).toThrow();
     });
     it('should accept a proper native android project path as construction parameter', function()
{
-        var project;
         expect(function() {
-            project = new android_parser(android_path);
+            var project = new android_parser(android_path);
+            expect(project).toBeDefined();
         }).not.toThrow();
-        expect(project).toBeDefined();
     });
 
     describe('update_from_config method', function() {
         var project, config;
+        
+        var android_strings = path.join(android_path, 'res', 'values', 'strings.xml');
+        var android_manifest = path.join(android_path, 'AndroidManifest.xml');
+        var android_config = path.join(android_path, 'res', 'xml', 'config.xml');
+
+        var original_strings = fs.readFileSync(android_strings, 'utf-8');
+        var original_manifest = fs.readFileSync(android_manifest, 'utf-8');
+        var original_android_config = fs.readFileSync(android_config, 'utf-8');
 
         beforeEach(function() {
             project = new android_parser(android_path);
-            config = new config_parser(cfg_path);
+            config = new config_parser(www_config);
         });
         afterEach(function() {
             fs.writeFileSync(android_strings, original_strings, 'utf-8');
             fs.writeFileSync(android_manifest, original_manifest, 'utf-8');
-            fs.writeFileSync(cfg_path, original_config, 'utf-8');
+            fs.writeFileSync(www_config, original_www_config, 'utf-8');
             fs.writeFileSync(android_config, original_android_config, 'utf-8');
         });
         it('should throw an exception if a non config_parser object is passed into it', function()
{
@@ -117,11 +118,11 @@ describe('android project parser', function() {
 
                 var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config,
'utf-8')));
                 var ps = native_config.findall('preference');
-                expect(ps.length).toEqual(3);
+                expect(ps.length).toEqual(7);
                 expect(ps[0].attrib.name).toEqual('useBrowserHistory');
                 expect(ps[0].attrib.value).toEqual('true');
-                expect(ps[2].attrib.name).toEqual('henrik');
-                expect(ps[2].attrib.value).toEqual('sedin');
+                expect(ps[6].attrib.name).toEqual('henrik');
+                expect(ps[6].attrib.value).toEqual('sedin');
             });
             it('should override a default project preference if applicable', function() {
                 config.preference.add({name:'useBrowserHistory',value:'false'});
@@ -129,64 +130,65 @@ describe('android project parser', function() {
 
                 var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config,
'utf-8')));
                 var ps = native_config.findall('preference');
-                expect(ps.length).toEqual(2);
+                expect(ps.length).toEqual(6);
                 expect(ps[0].attrib.name).toEqual('useBrowserHistory');
                 expect(ps[0].attrib.value).toEqual('false');
             });
         });
     });
 
-    describe('update_www method', function() {
-        var parser, android_platform;
+    describe('cross-platform project level methods', function() {
+        var parser, config;
+        var android_strings = path.join(android_project_path, 'res', 'values', 'strings.xml');
+        var android_manifest = path.join(android_project_path, 'AndroidManifest.xml');
+        var android_config = path.join(android_project_path, 'res', 'xml', 'config.xml');
 
-        beforeEach(function() {
-            shell.rm('-rf', tempDir);
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-            cordova.platform('add', 'android');
-            android_platform = path.join(tempDir, 'platforms', 'android');
-            parser = new android_parser(android_platform);
-        });
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-
-        it('should update all www assets', function() {
-            var newFile = path.join(tempDir, 'www', 'somescript.js');
-            fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
-            parser.update_www();
-            expect(fs.existsSync(path.join(android_platform, 'assets', 'www', 'somescript.js'))).toBe(true);
-        });
-        it('should write out android js to cordova.js', function() {
-            parser.update_www();
-            expect(fs.readFileSync(path.join(android_platform, 'assets', 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory,
'cordova-android', 'framework', 'assets', 'js', 'cordova.android.js'), 'utf-8'));
-        });
-    });
-
-    describe('update_project method', function() {
-        var parser, android_platform, cfg;
+        var original_strings = fs.readFileSync(android_strings, 'utf-8');
+        var original_manifest = fs.readFileSync(android_manifest, 'utf-8');
+        var original_android_config = fs.readFileSync(android_config, 'utf-8');
 
         beforeEach(function() {
-            shell.rm('-rf', tempDir);
-            cordova.create(tempDir);
-            process.chdir(tempDir);
-            cordova.platform('add', 'android');
-            android_platform = path.join(tempDir, 'platforms', 'android');
-            parser = new android_parser(android_platform);
-            cfg = new config_parser(cfg_path);
+            parser = new android_parser(android_project_path);
+            config = new config_parser(www_config);
         });
         afterEach(function() {
-            process.chdir(cwd);
+            fs.writeFileSync(android_strings, original_strings, 'utf-8');
+            fs.writeFileSync(android_manifest, original_manifest, 'utf-8');
+            fs.writeFileSync(www_config, original_www_config, 'utf-8');
+            fs.writeFileSync(android_config, original_android_config, 'utf-8');
         });
-        it('should invoke update_www', function() {
-            var spyWww = spyOn(parser, 'update_www');
-            parser.update_project(cfg);
-            expect(spyWww).toHaveBeenCalled();
+        describe('update_www method', function() {
+            it('should update all www assets', function() {
+                var newFile = path.join(project_path, 'www', 'somescript.js');
+                this.after(function() {
+                    shell.rm('-f', newFile);
+                });
+                fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
+                parser.update_www();
+                expect(fs.existsSync(path.join(android_project_path, 'assets', 'www', 'somescript.js'))).toBe(true);
+            });
+            it('should write out android js to cordova.js', function() {
+                parser.update_www();
+                expect(fs.readFileSync(path.join(android_project_path, 'assets', 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory,
'cordova-android', 'framework', 'assets', 'js', 'cordova.android.js'), 'utf-8'));
+            });
+            it('should call out to util.deleteSvnFolders', function() {
+                var spy = spyOn(util, 'deleteSvnFolders');
+                parser.update_www();
+                expect(spy).toHaveBeenCalled();
+            });
         });
-        it('should invoke update_from_config', function() {
-            var spyConfig = spyOn(parser, 'update_from_config');
-            parser.update_project(cfg);
-            expect(spyConfig).toHaveBeenCalled();
+
+        describe('update_project method', function() {
+            it('should invoke update_www', function() {
+                var spyWww = spyOn(parser, 'update_www');
+                parser.update_project(config);
+                expect(spyWww).toHaveBeenCalled();
+            });
+            it('should invoke update_from_config', function() {
+                var spyConfig = spyOn(parser, 'update_from_config');
+                parser.update_project(config);
+                expect(spyConfig).toHaveBeenCalled();
+            });
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ef109bd/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index ab22fee..16737be 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -128,7 +128,7 @@ module.exports.prototype = {
     },
 
     update_www:function() {
-        var projectRoot = util.isCordova(process.cwd());
+        var projectRoot = util.isCordova(this.path);
         var www = path.join(projectRoot, 'www');
         var platformWww = path.join(this.path, 'assets');
         // remove stock platform assets


Mime
View raw message