|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
const { run, stat, makeTempDir, remove, env } = Deno;
|
|
|
|
|
const { run, stat, makeTempDir, remove, env, readAll } = Deno;
|
|
|
|
|
|
|
|
|
|
import { test, runIfMain, TestFunction } from "../testing/mod.ts";
|
|
|
|
|
import { assert, assertEquals } from "../testing/asserts.ts";
|
|
|
|
@ -20,7 +20,6 @@ async function startFileServer(): Promise<void> {
|
|
|
|
|
"--allow-read",
|
|
|
|
|
"--allow-net",
|
|
|
|
|
"http/file_server.ts",
|
|
|
|
|
"--",
|
|
|
|
|
".",
|
|
|
|
|
"--cors"
|
|
|
|
|
],
|
|
|
|
@ -84,11 +83,11 @@ installerTest(async function installBasic(): Promise<void> {
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
|
|
|
|
|
@IF EXIST "%~dp0\deno.exe" (
|
|
|
|
|
"%~dp0\deno.exe" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" %*
|
|
|
|
|
"%~dp0\deno.exe" "run" "http://localhost:4500/installer/testdata/echo.ts" %*
|
|
|
|
|
) ELSE (
|
|
|
|
|
@SETLOCAL
|
|
|
|
|
@SET PATHEXT=%PATHEXT:;.TS;=;%
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" %*
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" %*
|
|
|
|
|
)
|
|
|
|
|
`
|
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
@ -107,10 +106,10 @@ case \`uname\` in
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ -x "$basedir/deno" ]; then
|
|
|
|
|
"$basedir/deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" "$@"
|
|
|
|
|
"$basedir/deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
else
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" "$@"
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
fi
|
|
|
|
|
exit $ret
|
|
|
|
@ -139,11 +138,11 @@ installerTest(async function installCustomDir(): Promise<void> {
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
|
|
|
|
|
@IF EXIST "%~dp0\deno.exe" (
|
|
|
|
|
"%~dp0\deno.exe" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" %*
|
|
|
|
|
"%~dp0\deno.exe" "run" "http://localhost:4500/installer/testdata/echo.ts" %*
|
|
|
|
|
) ELSE (
|
|
|
|
|
@SETLOCAL
|
|
|
|
|
@SET PATHEXT=%PATHEXT:;.TS;=;%
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" %*
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" %*
|
|
|
|
|
)
|
|
|
|
|
`
|
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
@ -162,10 +161,10 @@ case \`uname\` in
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ -x "$basedir/deno" ]; then
|
|
|
|
|
"$basedir/deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" "$@"
|
|
|
|
|
"$basedir/deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
else
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" "$@"
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
fi
|
|
|
|
|
exit $ret
|
|
|
|
@ -193,11 +192,11 @@ installerTest(async function installLocalModule(): Promise<void> {
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
|
|
|
|
|
@IF EXIST "%~dp0\deno.exe" (
|
|
|
|
|
"%~dp0\deno.exe" "run" "${localModule}" "--" %*
|
|
|
|
|
"%~dp0\deno.exe" "run" "${localModule}" %*
|
|
|
|
|
) ELSE (
|
|
|
|
|
@SETLOCAL
|
|
|
|
|
@SET PATHEXT=%PATHEXT:;.TS;=;%
|
|
|
|
|
"deno" "run" "${localModule}" "--" %*
|
|
|
|
|
"deno" "run" "${localModule}" %*
|
|
|
|
|
)
|
|
|
|
|
`
|
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
@ -216,10 +215,10 @@ case \`uname\` in
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ -x "$basedir/deno" ]; then
|
|
|
|
|
"$basedir/deno" "run" "${localModule}" "--" "$@"
|
|
|
|
|
"$basedir/deno" "run" "${localModule}" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
else
|
|
|
|
|
"deno" "run" "${localModule}" "--" "$@"
|
|
|
|
|
"deno" "run" "${localModule}" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
fi
|
|
|
|
|
exit $ret
|
|
|
|
@ -228,17 +227,57 @@ exit $ret
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* TODO(ry) Re-enable this test
|
|
|
|
|
installerTest(async function installWithFlags(): Promise<void> {
|
|
|
|
|
await install(
|
|
|
|
|
"echo_test",
|
|
|
|
|
"http://localhost:4500/installer/testdata/echo.ts",
|
|
|
|
|
["--allow-net", "--allow-read", "--foobar"]
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* TODO(ry) Re-enable this test
|
|
|
|
|
const { HOME } = env();
|
|
|
|
|
const filePath = path.resolve(HOME, ".deno/bin/echo_test");
|
|
|
|
|
|
|
|
|
|
if (path.isWindows) {
|
|
|
|
|
assertEquals(
|
|
|
|
|
await fs.readFileStr(filePath + ".cmd"),
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
|
|
|
|
|
@IF EXIST "%~dp0\deno.exe" (
|
|
|
|
|
"%~dp0\deno.exe" "run" "--allow-net" "--allow-read" "http://localhost:4500/installer/testdata/echo.ts" "--foobar" %*
|
|
|
|
|
) ELSE (
|
|
|
|
|
@SETLOCAL
|
|
|
|
|
@SET PATHEXT=%PATHEXT:;.TS;=;%
|
|
|
|
|
"deno" "run" "--allow-net" "--allow-read" "http://localhost:4500/installer/testdata/echo.ts" "--foobar" %*
|
|
|
|
|
)
|
|
|
|
|
`
|
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
await fs.readFileStr(filePath),
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
`#!/bin/sh
|
|
|
|
|
# This executable is generated by Deno. Please don't modify it unless you know what it means.
|
|
|
|
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
|
|
|
|
|
|
|
|
|
|
case \`uname\` in
|
|
|
|
|
*CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ -x "$basedir/deno" ]; then
|
|
|
|
|
"$basedir/deno" "run" "--allow-net" "--allow-read" "http://localhost:4500/installer/testdata/echo.ts" "--foobar" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
else
|
|
|
|
|
"deno" "run" "--allow-net" "--allow-read" "http://localhost:4500/installer/testdata/echo.ts" "--foobar" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
fi
|
|
|
|
|
exit $ret
|
|
|
|
|
`
|
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
installerTest(async function installLocalModuleAndRun(): Promise<void> {
|
|
|
|
|
const tempDir = await makeTempDir();
|
|
|
|
|
const localModule = path.join(Deno.cwd(), "installer", "testdata", "echo.ts");
|
|
|
|
@ -276,9 +315,7 @@ installerTest(async function installLocalModuleAndRun(): Promise<void> {
|
|
|
|
|
|
|
|
|
|
assert(!thrown, "It should not throw an error");
|
|
|
|
|
}, true); // set true to install module in your real $HOME dir.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* TODO(ry) Re-enable this test
|
|
|
|
|
installerTest(async function installAndMakesureItCanRun(): Promise<void> {
|
|
|
|
|
const tempDir = await makeTempDir();
|
|
|
|
|
await install(
|
|
|
|
@ -320,9 +357,7 @@ installerTest(async function installAndMakesureItCanRun(): Promise<void> {
|
|
|
|
|
|
|
|
|
|
assert(!thrown, "It should not throw an error");
|
|
|
|
|
}, true); // set true to install module in your real $HOME dir.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* TODO(ry) Re-enable this test
|
|
|
|
|
installerTest(async function installAndMakesureArgsRight(): Promise<void> {
|
|
|
|
|
const tempDir = await makeTempDir();
|
|
|
|
|
await install(
|
|
|
|
@ -350,7 +385,9 @@ installerTest(async function installAndMakesureArgsRight(): Promise<void> {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const b = await readAll(ps.stdout);
|
|
|
|
|
|
|
|
|
|
const s = new TextDecoder("utf-8").decode(b);
|
|
|
|
|
|
|
|
|
|
const obj = JSON.parse(s);
|
|
|
|
|
|
|
|
|
|
assertEquals(obj[0], "arg1");
|
|
|
|
@ -367,7 +404,6 @@ installerTest(async function installAndMakesureArgsRight(): Promise<void> {
|
|
|
|
|
|
|
|
|
|
assert(!thrown, "It should not throw an error");
|
|
|
|
|
}, true); // set true to install module in your real $HOME dir.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
installerTest(async function installWithoutHOMEVar(): Promise<void> {
|
|
|
|
|
const { HOME } = env();
|
|
|
|
@ -391,11 +427,11 @@ installerTest(async function installWithoutHOMEVar(): Promise<void> {
|
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
|
|
|
|
|
@IF EXIST "%~dp0\deno.exe" (
|
|
|
|
|
"%~dp0\deno.exe" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" %*
|
|
|
|
|
"%~dp0\deno.exe" "run" "http://localhost:4500/installer/testdata/echo.ts" %*
|
|
|
|
|
) ELSE (
|
|
|
|
|
@SETLOCAL
|
|
|
|
|
@SET PATHEXT=%PATHEXT:;.TS;=;%
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" %*
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" %*
|
|
|
|
|
)
|
|
|
|
|
`
|
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
@ -414,10 +450,10 @@ case \`uname\` in
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
if [ -x "$basedir/deno" ]; then
|
|
|
|
|
"$basedir/deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" "$@"
|
|
|
|
|
"$basedir/deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
else
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "--" "$@"
|
|
|
|
|
"deno" "run" "http://localhost:4500/installer/testdata/echo.ts" "$@"
|
|
|
|
|
ret=$?
|
|
|
|
|
fi
|
|
|
|
|
exit $ret
|
|
|
|
|