summaryrefslogtreecommitdiffstats
path: root/addon-sdk/source/test/fixtures/child-process-scripts.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-09 06:46:43 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-09 06:46:43 -0500
commitac46df8daea09899ce30dc8fd70986e258c746bf (patch)
tree2750d3125fc253fd5b0671e4bd268eff1fd97296 /addon-sdk/source/test/fixtures/child-process-scripts.js
parent8cecf8d5208f3945b35f879bba3015bb1a11bec6 (diff)
downloadUXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.gz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.lz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.xz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.zip
Move Add-on SDK source to toolkit/jetpack
Diffstat (limited to 'addon-sdk/source/test/fixtures/child-process-scripts.js')
-rw-r--r--addon-sdk/source/test/fixtures/child-process-scripts.js81
1 files changed, 0 insertions, 81 deletions
diff --git a/addon-sdk/source/test/fixtures/child-process-scripts.js b/addon-sdk/source/test/fixtures/child-process-scripts.js
deleted file mode 100644
index d808e56cb..000000000
--- a/addon-sdk/source/test/fixtures/child-process-scripts.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-'use strict';
-
-const { platform, pathFor } = require('sdk/system');
-const { defer } = require('sdk/core/promise');
-const { emit } = require('sdk/event/core');
-const { join } = require('sdk/fs/path');
-const { writeFile, unlinkSync, existsSync } = require('sdk/io/fs');
-const PROFILE_DIR= pathFor('ProfD');
-const isWindows = platform.toLowerCase().indexOf('win') === 0;
-const isOSX = platform.toLowerCase().indexOf('darwin') === 0;
-
-var scripts = {
- 'args.sh': 'echo $1 $2 $3 $4',
- 'args.bat': 'echo %1 %2 %3 %4',
- 'check-env.sh': 'echo $CHILD_PROCESS_ENV_TEST',
- 'check-env.bat': 'echo %CHILD_PROCESS_ENV_TEST%',
- 'check-pwd.sh': 'echo $PWD',
- 'check-pwd.bat': 'cd',
- 'large-err.sh': 'for n in `seq 0 $1` ; do echo "E" 1>&2; done',
- 'large-err-mac.sh': 'for ((i=0; i<$1; i=i+1)); do echo "E" 1>&2; done',
- 'large-err.bat': 'FOR /l %%i in (0,1,%1) DO echo "E" 1>&2',
- 'large-out.sh': 'for n in `seq 0 $1` ; do echo "O"; done',
- 'large-out-mac.sh': 'for ((i=0; i<$1; i=i+1)); do echo "O"; done',
- 'large-out.bat': 'FOR /l %%i in (0,1,%1) DO echo "O"',
- 'wait.sh': 'sleep 2',
- // Use `ping` to an invalid IP address because `timeout` isn't
- // on all environments? http://stackoverflow.com/a/1672349/1785755
- 'wait.bat': 'ping 1.1.1.1 -n 1 -w 2000 > nul'
-};
-
-Object.keys(scripts).forEach(filename => {
- if (/\.sh$/.test(filename))
- scripts[filename] = '#!/bin/sh\n' + scripts[filename];
- else if (/\.bat$/.test(filename))
- scripts[filename] = '@echo off\n' + scripts[filename];
-});
-
-function getScript (name) {
- // Use specific OSX script if exists
- if (isOSX && scripts[name + '-mac.sh'])
- name = name + '-mac';
- let fileName = name + (isWindows ? '.bat' : '.sh');
- return createFile(fileName, scripts[fileName]);
-}
-exports.getScript = getScript;
-
-function createFile (name, data) {
- let { promise, resolve, reject } = defer();
- let fileName = join(PROFILE_DIR, name);
- writeFile(fileName, data, function (err) {
- if (err) reject();
- else {
- makeExecutable(fileName);
- resolve(fileName);
- }
- });
- return promise;
-}
-
-// TODO Use fs.chmod once implemented, bug 914606
-function makeExecutable (name) {
- let { CC } = require('chrome');
- let nsILocalFile = CC('@mozilla.org/file/local;1', 'nsILocalFile', 'initWithPath');
- let file = nsILocalFile(name);
- file.permissions = 0o777;
-}
-
-function deleteFile (name) {
- let file = join(PROFILE_DIR, name);
- if (existsSync(file))
- unlinkSync(file);
-}
-
-function cleanUp () {
- Object.keys(scripts).forEach(deleteFile);
-}
-exports.cleanUp = cleanUp;