-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not spawn a shell to avoid having to deal with fileguards, see ubp…
- Loading branch information
1 parent
72c248d
commit 90cfd28
Showing
11 changed files
with
81 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from "fs"; | ||
|
||
const [, ...args] = process.argv; | ||
console.log(fs.statSync(args[1])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from "fs"; | ||
|
||
const [, ...args] = process.argv; | ||
console.log(fs.statSync(args[1])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use strict"; | ||
|
||
/* | ||
* Copyright (C) 2017-2019 UBports Foundation <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import chai from "chai"; | ||
import sinon from "sinon"; | ||
import sinonChai from "sinon-chai"; | ||
const expect = chai.expect; | ||
chai.use(sinonChai); | ||
|
||
import util from "util"; | ||
import { spawn, execFile } from "child_process"; | ||
const execFilePromise = util.promisify(execFile); | ||
const spawnPromise = (file, args) => | ||
new Promise((resolve, reject) => { | ||
const cp = spawn(file, args); | ||
cp.on("exit", code => (code ? reject({ code }) : resolve())); | ||
}); | ||
|
||
describe("platform", function() { | ||
["fake_fileaccesser", "fake fileaccesser"].forEach(e => { | ||
describe(e, function() { | ||
[ | ||
{ f: execFilePromise, n: "execFile" }, | ||
{ f: spawnPromise, n: "spawn" } | ||
].forEach(({ f, n }) => { | ||
it(`${n} should access path without spaces`, function() { | ||
return f(`tests/test-data/${e}.js`, ["tests/test-data/test_file"]); | ||
}); | ||
it(`${n} should access path with spaces`, function() { | ||
return f(`tests/test-data/${e}.js`, ["tests/test-data/test file"]); | ||
}); | ||
it(`${n} should throw on inaccessible path`, function(done) { | ||
f(`tests/test-data/${e}.js`, [ | ||
"tests/test-data/thisdoesntexist" | ||
]).catch(error => { | ||
expect(error).to.haveOwnProperty("code", 1); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters