profile
viewpoint

startedIntrinsicLabs/osgood

started time in 18 hours

issue commentblueimp/chromedriver

Tagging different versions

@blueimp do you have an example of or hint to what that might look like?

It seems like specifying the google chrome and chromedriver version isn't sufficient since they don't seem to play well with each other (at least for me I am getting unknown error: DevToolsActivePort file doesn't exist errors which may (?) be due to a version mismatch despite being in the same chrome major version).

carlesar

comment created time in 8 days

push eventhayd/deno_docker

Andy Hayden

commit sha 1a8b0cda9c371a3293ac820c989726efa671d79c

:whale: bump version to 0.7.0 Set DENO_DIR as /deno-cache/ directory Use deno USER rather than running as root

view details

Andy Hayden

commit sha 6649665553d520611e53df8b7c165289f2b70b2c

:whale: bump version to 0.11.0

view details

push time in 9 days

issue commentsimsong/tcpflow

installation issue on Amazon Linux 1

"Amazon Linux 1" is the os.

zhenyiy

comment created time in 13 days

pull request commentv8/v8

Travis CI: Use flake8 to find Python syntax errors

SyntaxError is just the start of the porting story, is there buy-in to run python 3 on CI? (Or is this already happening?)

cclauss

comment created time in 13 days

pull request commentv8/v8

Travis CI: Use flake8 to find Python syntax errors

Six months to go!

Is CI being run on python 3? Is there a good way to split up the future porting work (post syntax)? Presumably lots fail even with this patch?

cclauss

comment created time in 14 days

pull request commentdenoland/deno_std

add UUID module supporting v4

Just to confirm, this is based of this gist? https://gist.github.com/jed/982883#gistcomment-2886092

Is that not a concern? (I am a little confused whether this was code golf.)

lucascaro

comment created time in 15 days

issue commentdenoland/deno

Running setup script runs into multiple issues if Python 2 isn't setup as Path env var

The anaconda Python version parsing issue has been fixed upstream in Luci go... Maybe v8 doesn't have that yet? I thought this had been working for me (I use anaconda).

At the moment users have to ensure python points to python2. You could instead pass PATH to setup.py...

This feels like a bug in v8 scripts, that they should use sys.executable rather than hardcode 'python'.

What steps are you using for virtual env? I use conda's source activate py27..

exlunae

comment created time in 18 days

pull request commentdenoland/deno

Update rust for ci

I'm not sure this is sufficient to actually update rust in appveyor. I think it needs a cache clear.

afinch7

comment created time in 18 days

issue commenthayd/deno_docker

Add information about DENO_DIR

I also create a deno USER, this could either be the default (it is now 😬 ) or have users set USER prior to deno execution (fetch/run).

bartlomieju

comment created time in 19 days

issue commentdenoland/deno

installed programs should be able to take --reload argument

I still haven't heard a use case.

It seems to me this is a micro optimization for deno core developers.. but not useful for users.

ry

comment created time in 19 days

issue commentdenoland/deno

installed programs should be able to take --reload argument

The problem I have with this command (it was already prototyped in denoland/deno_std#512) is that you have to type full URL again

For an update there's no reason that has to be the case (you could reuse the existing if not passed).

I still don't see the use case for this, when/why would regular users want to do this?

ry

comment created time in 19 days

startedachillesrasquinha/pipupgrade

started time in 20 days

issue commentdenoland/deno

installed programs should be able to take --reload argument

One problem, which we had with --help is what if a deno program wants to use that. What is the usecase (why would a user want to do this)?

Is it easier/sufficient to do something like:

deno install --update catj https://deno.land/std/examples/catjson.ts --allow-read --refresh -L=info
ry

comment created time in 21 days

Pull request review commentdenoland/deno

Feature: Native plugins

 def filter_test_suite(suite, pattern):   def run_tests(test_cases=None):+    os.environ["DENO_BUILD_PATH"] = build_path()

related, this is also a little awkward in the ts file:

 const dLib = dlopen(env().DL_PATH_TEST_BINDING + "/" + dlname("test_plugin")); 

In the tests it seems like (in travis) you are only building release (I may be misreading that), so by "explicit" I mean link to the release plugin build...

Or is the issue in a debug deno you can't link to a release plugin?

afinch7

comment created time in 25 days

Pull request review commentbartlomieju/deno-postgres

Fix makeshift pool

 export class Client {    async end(): Promise<void> {     await this._connection.end();-    delete this._connection;   }    // Support `using` module   _aenter = this.connect;   _aexit = this.end; } -// TODO(bartlomieju) to be refactored-export class PooledClient extends Client {-  constructor(connection: Connection, release: () => void) {-    super();+export class PoolClient {+  protected _connection: Connection;+  private _releaseCallback: () => void;++  constructor(connection: Connection, releaseCallback: () => void) {     this._connection = connection;-    this.release = function() {-      release();-      delete this._connection;-      delete this.release;-    };+    this._releaseCallback = releaseCallback;   } -  async connect(): Promise<void> {}+  async query(+    text: string | QueryConfig,+    ...args: any[]+  ): Promise<QueryResult> {+    const query = new Query(text, ...args);+    return await this._connection.query(query);+  } -  async end(): Promise<void> {-    this.release();+  async release(): Promise<void> {+    await this._releaseCallback();

Isn't this now unsafe if called twice? (puts the connection back into the pool array twice).

bartlomieju

comment created time in a month

issue commentdenoland/deno

Bundling V2

@kitsonk Example:

 % deno bundle https://deno.land/std/prettier/main.ts
[10/10] Downloading https://raw.githubusercontent.com/denoland/deno_std/master/prettier/vendor/parser_markdown.jsBundling "main.bundle.js"
Emitting bundle to "main.bundle.js"
12.4 MB emitted.

 % deno -A https://deno.land/std/bundle/run.ts main.bundle.js x.ts
strictEqual failed. actual = 3 expected = 2
https://raw.githubusercontent.com/denoland/deno_std/master/testing/asserts.ts:118:14
        throw new AssertionError(msg);
              ^
Uncaught AssertionError: Expected exactly two arguments.
    at AssertionError (https://raw.githubusercontent.com/denoland/deno_std/master/testing/asserts.ts:11:5)
    at assertStrictEq (https://raw.githubusercontent.com/denoland/deno_std/master/testing/asserts.ts:150:11)
    at load (https://raw.githubusercontent.com/denoland/deno_std/master/bundle/utils.ts:101:3)
    at main (https://raw.githubusercontent.com/denoland/deno_std/master/bundle/run.ts:6:22)
    at https://raw.githubusercontent.com/denoland/deno_std/master/bundle/run.ts:11:1
kitsonk

comment created time in a month

issue commentrust-lang/rust

Result::unwrap()` on an `Err` value: ()', libcore/result.rs:945

The annoying part of this issue is that you have no idea/indication of which line called unwrap.

dongwangdw

comment created time in a month

issue commentdenoland/deno

Bundling V2

A minor issue: Deno.args doesn't work as expected (it uses unmodified args rather than what's passed to the bundle). The example I had was bundling fmt.

kitsonk

comment created time in a month

Pull request review commentdenoland/deno

Feature: Native plugins

 def filter_test_suite(suite, pattern):   def run_tests(test_cases=None):+    os.environ["DENO_BUILD_PATH"] = build_path()

What about writing the path explicitly? I think that would be preferable...

afinch7

comment created time in a month

Pull request review commentdenoland/deno

Feature: Native plugins

 def filter_test_suite(suite, pattern):   def run_tests(test_cases=None):+    os.environ["DENO_BUILD_PATH"] = build_path()

Can you just write the path explicitly? Overwriting build path env seems unnecessary/destructive.

Does the plugin need to be built to the same release/debug mode as deno itself?

afinch7

comment created time in a month

Pull request review commentdenoland/deno

Feature: Native plugins

 def filter_test_suite(suite, pattern):   def run_tests(test_cases=None):+    os.environ["DENO_BUILD_PATH"] = build_path()

is this necessary?

afinch7

comment created time in a month

Pull request review commentdenoland/deno

Feature: Native plugins

--console.log(-  "Hello World"-)+console.log("Hello World");

revert?

afinch7

comment created time in a month

pull request commentdenoland/registry

Add deno_init to database.json

adding travis/appveyor/azure would also be nice. 😬

maxuuell

comment created time in a month

issue commentdenoland/deno

support chome devtools

console.log not printing to stdout is a separate issue. This issue is about debugging with V8Inspector .

ry

comment created time in a month

issue commentdenoland/deno

deno fmt is slow

I thought maybe #2477 would fix this, but it seems not. On investigating I think it's not the downloads which are slow(est): it's compilation. You can see this when passing -D.

One thought is bundling but atm bundle doesn't support args (I don't think). The bundle is 12.4MB.

It'd be great to see some flamegraphs/something to see what is taking the time here...

ry

comment created time in a month

issue commentphusion/baseimage-docker

How to know the ubuntu version?

That link is not helpful since lsb_release is not found/installed.

You can do cat /etc/os-release to see it's 18.04.1 LTS for 0.11.

It'd be great to update to the latest (18.04.2)...

zmlccf

comment created time in a month

issue commentdenoland/deno

deno fmt is slow

Are these gzipped over the wire? Is deno using Accept-Encoding="gzip"?

ry

comment created time in a month

pull request commentdenoland/registry

Remove std modules from registry

I kinda think this should be done before 1.0

hayd

comment created time in a month

issue commentdenoland/deno

Promise exit behaviour

Could you explain what "the promise behaviour we were talking about" is?

benjamingr

comment created time in a month

startedQuantStack/mamba

started time in a month

pull request commentdenoland/deno

feat: log permission access

how about we introduce -I/--log-info?

:+1:

bartlomieju

comment created time in a month

issue commentdenoland/deno

Default to always printing log message when permissions are accessed

@bartlomieju IIUC this issue is distinct from the prompt.

get by default a list of files accessed even if --allow-read is on

ry

comment created time in a month

issue commentdenoland/deno

Default to always printing log message when permissions are accessed

A script that reads a hundred files from the current directory will log that many lines in stderr? That seems too verbose for a default.

I think a better (breaking) change would be for --allow-read to mean --allow-read=.

ry

comment created time in a month

issue commentdenoland/deno

Is there any JavaScript engine written in rust?

Even Servo, the biggest rust project, uses SpiderMonkey (not written in rust*). V8 is amazing... deno is not going to use something else soley because it's written in rust.

*HolyJIT was (is?) Mozilla's plan to create a new JS engine in rust. IMO this is still many years away. https://blog.mozilla.org/javascript/2017/10/20/holyjit-a-new-hope/

catastrop

comment created time in a month

issue commentdenoland/deno

deno fmt is slow

Is it preferable/faster to do something ourselves rather than shell out to prettier?

I was wondering if this is feasible to port: https://github.com/vvakame/typescript-formatter/blob/master/lib/formatter.ts

ry

comment created time in a month

pull request commentdenoland/deno

Move TestFmt to end of tests

Could we cp prettier std files into DENO_DIR cache, so as to avoid the download?

ry

comment created time in a month

issue commentdenoland/deno

website/style.css: Text gets cut off, even if the browser window is wide enough

You can scroll right on that pre, so I wouldn't fix this... (a fix is likely going to look ugly). You can read the intent of, and copy and paste, the code which is the important thing...

ry

comment created time in a month

pull request commentdenoland/deno

build improvements for packagers of deno

This is now used in homebrew! 😎 https://github.com/Homebrew/homebrew-core/pull/40811 Thanks again @chrmoritz.

chrmoritz

comment created time in a month

Pull request review commentdenoland/deno

feat: default output filename for deno bundle

 OPTIONS:  SUBCOMMANDS:     <script>    Script to run+    bundle      Bundle module and dependnecies into single file

typo: s/dependnecies/dependencies

ry

comment created time in a month

issue commentdenoland/deno

Rewrite deno_dir.rs

@kitsonk please take it.

ry

comment created time in a month

CommitCommentEvent
CommitCommentEvent

push eventhayd/deno

Andy Hayden

commit sha 5c62d4a55d5d61fb513a45ae17a21ddb5b70e42a

tests: use verbosity=2 as the default

view details

push time in a month

push eventhayd/deno

Andy Hayden

commit sha da2e8982f5f0be1af8bead79731a3daa56b17eb1

tests: use verbosity=2 as the default

view details

push time in a month

pull request commentdenoland/deno

chore: make tests quieter

In this branch you need to use -vv to show the http_server requests. Sure, we could do -v as the default, the single dot output is a little overly concise...

hayd

comment created time in a month

Pull request review commentdenoland/deno

chore: make tests quieter

 def run(args, quiet=False, cwd=None, env=None, merge_env=None):         sys.exit(rc)  -def run_output(args, quiet=False, cwd=None, env=None, merge_env=None):+CmdResult = collections.namedtuple('CmdResult', ['out', 'err', 'code'])+++def run_output(args,+               quiet=False,+               cwd=None,+               env=None,+               merge_env=None,+               exit_on_fail=False):     if merge_env is None:         merge_env = {}     args[0] = os.path.normpath(args[0])     if not quiet:         print " ".join(args)     env = make_env(env=env, merge_env=merge_env)     shell = os.name == "nt"  # Run through shell to make .bat/.cmd files work.-    return subprocess.check_output(args, cwd=cwd, env=env, shell=shell)+    p = subprocess.Popen(+        args,+        cwd=cwd,+        env=env,+        shell=shell,+        stdout=subprocess.PIPE,+        stderr=subprocess.PIPE)+    try:+        out, err = p.communicate()+    except subprocess.CalledProcessError as e:+        p.kill()+        p.wait()+        raise e+    retcode = p.poll()+    if retcode and exit_on_fail:+        sys.exit(retcode)+    # Ignore Windows CRLF (\r\n).+    return CmdResult(+        out.replace('\r\n', '\n'), err.replace('\r\n', '\n'), retcode)

To capture stderr.

hayd

comment created time in a month

Pull request review commentdenoland/deno

chore: make tests quieter

 ANOTHER_REDIRECT_PORT = 4547 DOUBLE_REDIRECTS_PORT = 4548 +QUIET = '-vv' not in sys.argv and sys.argv.count('-v') < 2

I think not since it's imported by benchmark.py and maybe others, which have different args than test.py...

hayd

comment created time in a month

PR opened denoland/deno

chore: make tests quieter

Don't mix http request logging in with the tests output. Don't print that the file servers are starting unless -vv flag is passed.

Capture the output of run with run_output which returns stdout, stderr and exit_code. Test against exit_code rather than relying on sys.exit.

cc @bartlomieju @ry

<!-- Before submitting a PR read https://deno.land/manual.html#contributing -->

+115 -59

0 comment

12 changed files

pr created time in a month

create barnchhayd/deno

branch : quiet-server

created branch time in a month

issue commentdenoland/deno

2019-06-05 benchmark page isn't being updated

Actually, I don't see how it can be that.

Perhaps we could add those two files to the .gitignore ? As it seems to still be an issue.

ry

comment created time in a month

issue commentdenoland/deno

2019-06-05 benchmark page isn't being updated

I don't think /tools/benchmark.py was modified in tools/test.py change? https://github.com/denoland/deno/commits/master/tools/benchmark.py

Ah, I wonder if it's there's no spawned server?

I wonder if it should be:

if __name__ == '__main__':
    with http_server.spawn():
        main(sys.argv)

Ooops, my bad for not spotting that!

ry

comment created time in a month

issue commentdenoland/deno

"deno https://deno.land/welcome.ts" should work

An alternative is to output that as a suggestion... Or a warning to stderr to prefer use of explicit run command.

ry

comment created time in a month

pull request commentdenoland/deno

chore: finish tests refactor

The reason I mentioned -vv is I have a branch to quiet the file server unless you pass -vv. I think that makes the tests easier to read locally. Good idea?

Ideally we'd capture the stdout/stderr and only output if there's an error. There's still a little noise coming from somewhere (or was prior to this PR anyway).

bartlomieju

comment created time in a month

pull request commentdenoland/deno

chore: finish tests refactor

Lgtm

bartlomieju

comment created time in a month

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

+#!/usr/bin/env python+# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.+# Runs the full test suite.+# Usage: ./tools/test.py out/Debug+import argparse+import os+import sys+import unittest++from util import (enable_ansi_colors, build_path, RESET, FG_RED, FG_GREEN,+                  executable_suffix, run, run_output, rmtree, tests_path)+++class DenoTestCase(unittest.TestCase):+    @classmethod+    def setUpClass(cls):+        args = parse_test_args()++        cls.build_dir = args.build_dir+        cls.deno_exe = args.executable+++# overload the test result class+class ColorTextTestResult(unittest.TextTestResult):+    def getDescription(self, test):+        name = str(test)+        if name.startswith("test_"):+            name = name[5:]+        return name++    def addSuccess(self, test):+        if self.showAll:+            self.stream.write(FG_GREEN)+        super(ColorTextTestResult, self).addSuccess(test)+        if self.showAll:+            self.stream.write(RESET)++    def addError(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addError(test, err)+        if self.showAll:+            self.stream.write(RESET)++    def addFailure(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addFailure(test, err)+        if self.showAll:+            self.stream.write(RESET)+++class ColorTextTestRunner(unittest.TextTestRunner):+    resultclass = ColorTextTestResult+++def create_test_arg_parser():+    parser = argparse.ArgumentParser()+    parser.add_argument(+        '--failfast', '-f', action='store_true', help='Stop on first failure')+    parser.add_argument(+        '--verbose', '-v', action='store_true', help='Verbose output')

I think you need to change the usage of this too, if you were going to change it (from --verbosity).

Does TextTestRunner do something different with verbosity > 2 (-vv)?

bartlomieju

comment created time in a month

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

+#!/usr/bin/env python+# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.+# Runs the full test suite.+# Usage: ./tools/test.py out/Debug+import argparse+import os+import sys+import unittest++from util import (enable_ansi_colors, build_path, RESET, FG_RED, FG_GREEN,+                  executable_suffix, run, run_output, rmtree, tests_path)+++class DenoTestCase(unittest.TestCase):+    @classmethod+    def setUpClass(cls):+        args = parse_test_args()++        cls.build_dir = args.build_dir+        cls.deno_exe = args.executable+++# overload the test result class+class ColorTextTestResult(unittest.TextTestResult):+    def getDescription(self, test):+        name = str(test)+        if name.startswith("test_"):+            name = name[5:]+        return name++    def addSuccess(self, test):+        if self.showAll:+            self.stream.write(FG_GREEN)+        super(ColorTextTestResult, self).addSuccess(test)+        if self.showAll:+            self.stream.write(RESET)++    def addError(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addError(test, err)+        if self.showAll:+            self.stream.write(RESET)++    def addFailure(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addFailure(test, err)+        if self.showAll:+            self.stream.write(RESET)+++class ColorTextTestRunner(unittest.TextTestRunner):+    resultclass = ColorTextTestResult+++def create_test_arg_parser():+    parser = argparse.ArgumentParser()+    parser.add_argument(+        '--failfast', '-f', action='store_true', help='Stop on first failure')+    parser.add_argument(+        '--verbosity', '-v', action='store_true', help='Verbose output')+    parser.add_argument("--executable", help="Use external executable of Deno")

Atm it's the position argument. See code below

bartlomieju

comment created time in a month

issue commentdenoland/deno

can local module imported like this "vendor/colors/mod" ?

You can already do this: specify DENO_DIR in the repo and commit the cached files.

satishbabariya

comment created time in a month

pull request commentdenoland/deno

chore: finish tests refactor [do not merge]

@ry Yep, this branch will fix that (with --pattern instead, and a shared arg parser). Note it was never working in master.

bartlomieju

comment created time in a month

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

+#!/usr/bin/env python+# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.+# Runs the full test suite.+# Usage: ./tools/test.py out/Debug+import argparse+import os+import sys+import unittest++from util import (enable_ansi_colors, build_path, RESET, FG_RED, FG_GREEN,+                  executable_suffix, run, run_output, rmtree, tests_path)+++class DenoTestCase(unittest.TestCase):+    @classmethod+    def setUpClass(cls):+        args = parse_test_args()++        cls.build_dir = args.build_dir+        cls.deno_exe = args.executable+++# overload the test result class+class ColorTextTestResult(unittest.TextTestResult):+    def getDescription(self, test):+        name = str(test)+        if name.startswith("test_"):+            name = name[5:]+        return name++    def addSuccess(self, test):+        if self.showAll:+            self.stream.write(FG_GREEN)+        super(ColorTextTestResult, self).addSuccess(test)+        if self.showAll:+            self.stream.write(RESET)++    def addError(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addError(test, err)+        if self.showAll:+            self.stream.write(RESET)++    def addFailure(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addFailure(test, err)+        if self.showAll:+            self.stream.write(RESET)+++class ColorTextTestRunner(unittest.TextTestRunner):+    resultclass = ColorTextTestResult+++def create_test_arg_parser():+    parser = argparse.ArgumentParser()+    parser.add_argument(+        '--failfast', '-f', action='store_true', help='Stop on first failure')+    parser.add_argument(+        '--verbosity', '-v', action='store_true', help='Verbose output')+    parser.add_argument("--executable", help="Use external executable of Deno")

Should we make --deno-dir a kwarg too (rather than position)? I think that's clearer.

Also, I guess required=False below is not required (my mistake).

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 class ColorTextTestRunner(unittest.TextTestRunner):     resultclass = ColorTextTestResult  -def test_main():+def test_main(suite=None):     args = parse_test_args() -    return unittest.main(-        verbosity=args.verbosity + 1,-        testRunner=ColorTextTestRunner,-        failfast=args.failfast,-        argv=[''])+    loader = unittest.TestLoader()++    # if suite was not explicitly passed load test+    # cases from calling module+    if suite is None:+        import __main__+        suite = loader.loadTestsFromModule(__main__)++    # TODO: should `args.pattern` be called filter?+    if args.pattern:+        filtered_tests = []++        for nested_suite in suite:+            for test_case in nested_suite:+                if args.pattern in str(test_case):+                    filtered_tests.append(test_case)

why no list comprehension? 😞

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 class ColorTextTestRunner(unittest.TextTestRunner):     resultclass = ColorTextTestResult  -def test_main():+def test_main(suite=None):     args = parse_test_args() -    return unittest.main(-        verbosity=args.verbosity + 1,-        testRunner=ColorTextTestRunner,-        failfast=args.failfast,-        argv=[''])+    loader = unittest.TestLoader()++    # if suite was not explicitly passed load test+    # cases from calling module+    if suite is None:+        import __main__+        suite = loader.loadTestsFromModule(__main__)++    # TODO: should `args.pattern` be called filter?

pattern is from discover api, so i think it's fine. Note: this allows -p TestTarget.

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def test_fetch(self):  if __name__ == "__main__":     with spawn():-        test_main()+        parse_test_args()

typo?

bartlomieju

comment created time in 2 months

pull request commentdenoland/deno

chore: finish tests refactor [do not merge]

looking good! the test_main with pattern filtering should work with the above code, passing suite or using __main__ (but feels a little hackier than yours).

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def test_args(argv=None):     parser.add_argument(         '--release',         action='store_true',-        help='Test against release deno_executable')+        help='Test against release executable')+    parser.add_argument(+        '--pattern',+        '-p',+        required=False,+        help='Run tests that match provided pattern')     parser.add_argument('build_dir', nargs='?', help='Deno build directory')-    args = parser.parse_args(argv)+    return parser+++TestArgParser = create_test_arg_parser()+++def parse_test_args(argv=None):+    if argv is None:+        argv = sys.argv[1:]++    args = TestArgParser.parse_args(argv)+     if args.build_dir and args.release:         raise argparse.ArgumentError(             None, "build_dir is inferred from --release, cannot provide both")+     if not args.build_dir:         args.build_dir = build_path() -    if not os.path.isfile(-            os.path.join(args.build_dir, "deno" + executable_suffix)):+    exe_path = os.path.join(args.build_dir, "deno" + executable_suffix)

args.executable = args.executable or os.path.join(args.build_dir, "deno" + executable_suffix)

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def mkdtemp():   class DenoTestCase(unittest.TestCase):-    @property-    def build_dir(self):-        args = test_args()-        return args.build_dir+    @classmethod+    def setUpClass(cls):+        args = parse_test_args() -    @property-    def deno_exe(self):-        return os.path.join(self.build_dir, "deno" + executable_suffix)+        cls.build_dir = args.build_dir+        cls.deno_exe = os.path.join(args.build_dir, "deno" + executable_suffix)

Perhaps we can use args.executable or os.path.join(args.build_dir, "deno" + executable_suffix)

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def mkdtemp():   class DenoTestCase(unittest.TestCase):-    @property-    def build_dir(self):-        args = test_args()-        return args.build_dir+    @classmethod+    def setUpClass(cls):+        args = parse_test_args()

This will be run for each TestCase? We should cache (run once) as you suggested.

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def generate(self, test_filename):  def main():     parser = argparse.ArgumentParser()-    parser.add_argument("--filter", help="Run specific tests")+    parser.add_argument("--filter", type=str, help="Run specific tests")

I think we can use the same arg parser (parse_test_args) as everywhere else (use .pattern and add --executable).

bartlomieju

comment created time in 2 months

issue commentdenoland/deno

can local module imported like this "vendor/colors/mod" ?

Maybe the error output could suggest using .ts or .js as a compromise here.

satishbabariya

comment created time in 2 months

pull request commentdenoland/deno

[WIP] Feature: Native bindings

Is one benefit to using import is it can be done at compile/fetch, e.g. import { opOpen, opRead } from ...?

afinch7

comment created time in 2 months

pull request commentdenoland/deno

chore: finish tests refactor [do not merge]

For part one:

def test_main(suite=None, argv=None):
    args = test_args(argv)
    pattern = args.pattern or ''

    if suite is None:
        import __main__
        suite = unittest.TestLoader().loadTestsFromModule(__main__)
    suite = unittest.TestSuite([test for s in suite for test in s if pattern in str(test)])

    runner = ColorTextTestRunner(verbosity=args.verbosity + 1, failfast=args.failfast)
    result = runner.run(suite)
    if not result.wasSuccessful():
        sys.exit(1)
    parser.add_argument(
        '--pattern', '-p',
        required=False,
        help='Run tests that include this string')

seems to work well.

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno_std

[Testing] Pretty output + Silent mode

 export function test(t: TestDefinition | TestFunction): void { }  const RED_FAILED = red("FAILED");-const GREEN_OK = green("ok");+const GREEN_OK = green("OK");

ok matches the python (etc?) output.

(FAILED is in all caps as it is bad 😄 )

zekth

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def mkdtemp(): class DenoTestCase(unittest.TestCase):     @property     def build_dir(self):+        # TODO(bartlomieju): cache         args = test_args()

You're right, you can do something like:

def test_args(argv=None, cache={}):
  argv = tuple(argv) if argv else None
  if argv in cache:
    return cache[argv]
  ...
  cache[argv] = res
  return res

or... something.

I think there's a clean path here that we're close to.

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 import time import unittest -# FIXME support nocolor (use "" if passed?)-RESET = "\x1b[0m"-FG_RED = "\x1b[31m"-FG_GREEN = "\x1b[32m"+if os.environ.get("NO_COLOR", None):+    RESET = FG_READ = FG_GREEN = ""

The "ok" is on a new line, unlike on max/linux:

032_xeval_delim (integration_tests.TestIntegrations) ... 
ok
async_error (integration_tests.TestIntegrations) ... 
ok
circular1 (integration_tests.TestIntegrations) ... 
ok
config (integration_tests.TestIntegrations) ... 
ok

This is kind of an aside, but was the impetus for me making the NO_COLOR comment!

bartlomieju

comment created time in 2 months

pull request commentdenoland/deno

chore: finish tests refactor [do not merge]

This is nice, thanks for cleaning the parts I omitted @bartlomieju .

Further, I think there are two main things that would be nice to clean (in the future):

  • parsing args (should shared for test.py and every other file).
  • BUILD_DIR and other envs, should be consistently handled, at the moment this feels pretty random / littered in the tests.

(Probably both can happen in test_main and that can be used everywhere.)

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def mkdtemp(): class DenoTestCase(unittest.TestCase):     @property     def build_dir(self):+        # TODO(bartlomieju): cache         args = test_args()

Perhaps it suffices to do:

@functools.lru_cache()
def test_args():
   ...

I had thought that might be too clever, but perhaps it's not so bad.

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 import time import unittest -# FIXME support nocolor (use "" if passed?)-RESET = "\x1b[0m"-FG_RED = "\x1b[31m"-FG_GREEN = "\x1b[32m"+if os.environ.get("NO_COLOR", None):+    RESET = FG_READ = FG_GREEN = ""

This still doesn't work on appveyor, is that an appveyor bug or a Windows one? (should we set NO_COLOR on appveyor?)

https://ci.appveyor.com/project/deno/deno/builds/24934612

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def main(argv):      enable_ansi_colors() -    with spawn():-        test_cases = [-            TestSetup,-            TestUtil,-            TestTarget,-            JsUnitTests,-            FetchTest,-            FmtTest,-            TestIntegrations,-            TestRepl,-            TestDenoDir,-            TestBenchmark,-        ]-        # These tests are skipped, but to make the test output less noisy-        # we'll avoid triggering them.-        if os.name != 'nt':-            test_cases.append(TestIsTty)-            test_cases += permission_prompt_tests()-            test_cases += complex_permissions_tests()--        suite = unittest.TestSuite([-            unittest.TestLoader().loadTestsFromTestCase(tc)-            for tc in test_cases-        ])--        result = ColorTextTestRunner(-            verbosity=args.verbosity + 1, failfast=args.failfast).run(suite)+    test_cases = [+        TestSetup,+        TestUtil,+        TestTarget,+        JsUnitTests,+        FetchTest,+        FmtTest,+        TestIntegrations,+        TestRepl,+        TestDenoDir,+        TestBenchmark,+        TestIsTty,+    ]+    test_cases += permission_prompt_tests()+    test_cases += complex_permissions_tests()++    suite = unittest.TestSuite(+        [unittest.TestLoader().loadTestsFromTestCase(tc) for tc in test_cases])++    runner = ColorTextTestRunner(+        verbosity=args.verbosity + 1, failfast=args.failfast)++    with http_server.spawn():+        result = runner.run(suite)

clever dedent!

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def main(argv):      enable_ansi_colors() -    with spawn():-        test_cases = [-            TestSetup,-            TestUtil,-            TestTarget,-            JsUnitTests,-            FetchTest,-            FmtTest,-            TestIntegrations,-            TestRepl,-            TestDenoDir,-            TestBenchmark,-        ]-        # These tests are skipped, but to make the test output less noisy-        # we'll avoid triggering them.-        if os.name != 'nt':-            test_cases.append(TestIsTty)-            test_cases += permission_prompt_tests()-            test_cases += complex_permissions_tests()--        suite = unittest.TestSuite([-            unittest.TestLoader().loadTestsFromTestCase(tc)-            for tc in test_cases-        ])--        result = ColorTextTestRunner(-            verbosity=args.verbosity + 1, failfast=args.failfast).run(suite)+    test_cases = [+        TestSetup,+        TestUtil,+        TestTarget,+        JsUnitTests,+        FetchTest,+        FmtTest,+        TestIntegrations,+        TestRepl,+        TestDenoDir,+        TestBenchmark,+        TestIsTty,+    ]+    test_cases += permission_prompt_tests()+    test_cases += complex_permissions_tests()

Note: This does make the windows tests very noisy!

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def main():         rmtree(deno_dir)     os.environ["DENO_DIR"] = deno_dir +    test_names = unittest.TestLoader().getTestCaseNames(TestIntegrations)     test_names = [-        test_name for test_name in unittest.TestLoader().getTestCaseNames(-            TestIntegrations) if not args.filter or args.filter in test_name+        test_name for test_name in test_names+        if not args.filter or args.filter in test_name

👍

I may have broken this filter stuff in the last commit (it didn't used to work on master), since the --filter is rejected by unittest.main. Ideally we'd refactor this so that both test.py and test_main supports filtering.

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: finish tests refactor [do not merge]

 def _run_deno(self, flags, args):         return tty_capture(cmd, b'')  -class TestReadPermissions(BaseComplexPermissionTest):-    test_type = "read"-+class BaseReadWritePermissionsTest(BaseComplexPermissionTest):

How does this work without test_type? Should be called ReadWritePermissionsTestMixin and subclass object?

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 def main():     args = parser.parse_args()      target = "release" if args.release else "debug"--    build_dir = None-    if "DENO_BUILD_PATH" in os.environ:-        build_dir = os.environ["DENO_BUILD_PATH"]-    else:-        build_dir = os.path.join(root_path, "target", target)+    build_dir = os.environ.get("DENO_BUILD_PATH",+                               os.path.join(root_path, "target", target))      deno_dir = os.path.join(build_dir, ".deno_test")     if os.path.isdir(deno_dir):         rmtree(deno_dir)     os.environ["DENO_DIR"] = deno_dir -    deno_exe = os.path.join(build_dir, "deno" + executable_suffix)-    if args.executable:-        deno_exe = args.executable+    test_names = [

yeah, this is a mess. actually the filter part here was just stubbed in before, and i made it work... can probably drop it for now.

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 # -*- coding: utf-8 -*- # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import os-import pty-import select import subprocess import sys import time import unittest -import http_server-from util import build_path, root_path, executable_suffix, green_ok, red_failed+from http_server import Spawn+from util import DenoTestCase, root_path, test_main, tty_capture  PERMISSIONS_PROMPT_TEST_TS = "tools/complex_permissions_test.ts"  PROMPT_PATTERN = b'⚠️' PERMISSION_DENIED_PATTERN = b'PermissionDenied: permission denied'  -# This function is copied from:-# https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e-# https://stackoverflow.com/q/52954248/1240268-def tty_capture(cmd, bytes_input, timeout=5):-    """Capture the output of cmd with bytes_input to stdin,-    with stdin, stdout and stderr as TTYs."""-    mo, so = pty.openpty()  # provide tty to enable line-buffering-    me, se = pty.openpty()-    mi, si = pty.openpty()-    fdmap = {mo: 'stdout', me: 'stderr', mi: 'stdin'}--    timeout_exact = time.time() + timeout-    p = subprocess.Popen(-        cmd, bufsize=1, stdin=si, stdout=so, stderr=se, close_fds=True)-    os.write(mi, bytes_input)--    select_timeout = .04  #seconds-    res = {'stdout': b'', 'stderr': b''}-    while True:-        ready, _, _ = select.select([mo, me], [], [], select_timeout)-        if ready:-            for fd in ready:-                data = os.read(fd, 512)-                if not data:-                    break-                res[fdmap[fd]] += data-        elif p.poll() is not None or time.time(-        ) > timeout_exact:  # select timed-out-            break  # p exited-    for fd in [si, so, se, mi, mo, me]:-        os.close(fd)  # can't do it sooner: it leads to errno.EIO error-    p.wait()-    return p.returncode, res['stdout'], res['stderr']---class ComplexPermissionTestCase(unittest.TestCase):-    def __init__(self, method_name, test_type, deno_exe):-        super(ComplexPermissionTestCase, self).__init__(method_name)-        self.test_type = test_type-        self.deno_exe = deno_exe-+@unittest.skipIf(os.name == 'nt', "Unable to test tty on Windows")+class BaseComplexPermissionTest(DenoTestCase):     def _run_deno(self, flags, args):         "Returns (return_code, stdout, stderr)."         cmd = ([self.deno_exe, "run", "--no-prompt"] + flags +                [PERMISSIONS_PROMPT_TEST_TS] + args)         return tty_capture(cmd, b'')  -class TestReadWritePermissions(ComplexPermissionTestCase):+class TestReadWritePermissions(BaseComplexPermissionTest):+    test_type = "read"

Can you look over this one? I subclassed this so it runs... perhaps there's a better way in the future.

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 def double_redirects_server():     return base_redirect_server(DOUBLE_REDIRECTS_PORT, REDIRECT_PORT)  +def start(s):+    thread = Thread(target=s.serve_forever, kwargs={"poll_interval": 0.05})+    thread.daemon = True+    thread.start()+    return thread++ def spawn():     # Main http server     s = server()-    thread = Thread(target=s.serve_forever)-    thread.daemon = True-    thread.start()+    thread = start(s)     # Redirect server     rs = redirect_server()-    r_thread = Thread(target=rs.serve_forever)-    r_thread.daemon = True-    r_thread.start()+    r_thread = start(rs)     # Another redirect server     ars = another_redirect_server()-    ar_thread = Thread(target=ars.serve_forever)-    ar_thread.daemon = True-    ar_thread.start()+    ar_thread = start(ars)     # Double redirects server     drs = double_redirects_server()-    dr_thread = Thread(target=drs.serve_forever)-    dr_thread.daemon = True-    dr_thread.start()+    dr_thread = start(drs)     sleep(1)  # TODO I'm too lazy to figure out how to do this properly.-    return thread+    return [s, rs, ars, drs], [thread, r_thread, ar_thread, dr_thread]+++class Spawn():

I'd forgotten you could do this, it's huge improvement. 👍

hayd

comment created time in 2 months

push eventhayd/deno

Axetroy

commit sha 4c80394f54bf68e8e961fbc6275cd536717bc7f6

bump std/prettier@0.5.0 to std/prettier@0.7.0 (#2425)

view details

Christian Moritz

commit sha 15dadf812c95c3dd2b93b1ba41ef488baeeac0c1

tools/third_party: add DENO_GN_PATH and DENO_NINJA_PATH env vars

view details

Christian Moritz

commit sha 0e780e894854cada1244aa3f465c226593187edc

tools/setup: don't download sccache if --no-binary-download is passed

view details

Bert Belder

commit sha 1540b36ce7a4740f4a87c564becca65ed8d97255

third_party: upgrade rust crates

view details

Andy Hayden

commit sha e23f1803bd0459ff93681e1c001bec1561ca5dc7

chore: refactor python tests to use unittest Move every test to a method on DenoTestCase. test.py is a single TestSuite of every TestCase. Add a Spawn context manager for http_server, this is explicitly used where it's needed. Each python test file can now be run independently without needing to manually run http_server. Add --help and consistent flags using argparse for each python test, including --failfast. Use ColorTextTestRunner so that '... ok' is green.

view details

Andy Hayden

commit sha 6780c5594d93dc40847f045afd6528da5b11c3f6

try to get better assertion message

view details

Andy Hayden

commit sha e5d025afa101b2509005e4e28a693bc89b5ae47d

Address feedback

view details

push time in 2 months

push eventhayd/deno

Andy Hayden

commit sha d3d5f8ffbf9fb29e6049feef274dc5cc59a2487d

lint

view details

push time in 2 months

push eventhayd/deno

Ryan Dahl

commit sha 53b6356ec5eac1c84610c2d2e75b527485c47f3c

Correct tokio_util::block_on() and op_fetch_module_meta_data op_fetch_module_meta_data is an op that is used by the TypeScript compiler. TypeScript requires this op to be sync. However the implementation of the op does things on the event loop (like fetching HTTP resources). In certain situations this can lead to deadlocks. The runtime's thread pool can be filled with ops waiting on the result of op_fetch_module_meta_data. The runtime has a maximum number of threads it can use (the number of logical CPUs on the system). This patch changes tokio_util::block_on to launch a new Tokio runtime for evaluating the future, thus bipassing the max-thread problem. This is only an issue in op_fetch_module_meta_data. Other synchronous ops are truly synchornous, not interacting with the event loop. TODO comments are added to direct future development.

view details

Ryan Dahl

commit sha 64d2b7bc90cf6fdba661d6d3fe243fe332c076ee

Change tools/fmt_test.py to always download prettier This is to ensure a more fair test. Also we were already downloading from the internet since we changed the URL to use std@v0.5.0. This change exposes an OOM bug, which is then fixed in the upcoming compiler refactor by changing checkJs compiler option to false.

view details

Ryan Dahl

commit sha 856c44213b7faf507d4b481cfc170b2fd08f971a

TS compiler refactor * Compiler no longer has its own Tokio runtime. Compiler handles one message and then exits. * Uses the simpler ts.CompilerHost interface instead of ts.LanguageServiceHost. * avoids recompiling the same module by introducing a hacky but simple `hashset<string>` that stores the module names that have been already compiled. * Removes the CompilerConfig op. * Removes a lot of the mocking stuff in compiler.ts like `this._ts`. It is not useful as we don't even have tests. * Turns off checkJs because it causes fmt_test to die with OOM.

view details

Ryan Dahl

commit sha 5265bd7cb1f86af99b01d73c537d52a50df95fe2

v0.7.0

view details

Andy Hayden

commit sha e2bac99f27c0e904fc3ce40c70c37954e22ac671

chore: refactor python tests to use unittest Move every test to a method on DenoTestCase. test.py is a single TestSuite of every TestCase. Add a Spawn context manager for http_server, this is explicitly used where it's needed. Each python test file can now be run independently without needing to manually run http_server. Add --help and consistent flags using argparse for each python test, including --failfast. Use ColorTextTestRunner so that '... ok' is green.

view details

Andy Hayden

commit sha f849bfe376e67f7f23081bf6b948f593029c194b

try to get better assertion message

view details

Andy Hayden

commit sha 05b78e3103e6a9e3688204f4f9fd1a3153a0cbd3

Address feedback

view details

Andy Hayden

commit sha a3c4db9826e9842ab4b1c35a7dcfa42b54a9b081

Address feedback

view details

push time in 2 months

push eventhayd/deno

Andy Hayden

commit sha f16a58f801c46b9dd03e8c64b651c19fb199bac0

Address feedback

view details

push time in 2 months

issue commentdenoland/deno

option to setup/build only use native

@chrmoritz Please can you make a PR from that branch, this would be really useful outside of brew.

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 def mkdtemp():     # 'TS5009: Cannot find the common subdirectory path for the input files.'     temp_dir = os.environ["TEMP"] if os.name == 'nt' else None     return tempfile.mkdtemp(dir=temp_dir)+++class DenoTestCase(unittest.TestCase):+    @property+    def build_dir(self):+        args = test_args()+        return args.build_dir

This is quite fiddly (it can be cached but it feels like duct tape). I'll need to think about this a little bit.

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 import os import subprocess import sys-from util import rmtree, run +from util import DenoTestCase, mkdtemp, rmtree, run, test_main -def deno_dir_test(deno_exe, deno_dir):-    assert os.path.isfile(deno_exe) -    old_deno_dir = None-    if "DENO_DIR" in os.environ:-        old_deno_dir = os.environ["DENO_DIR"]-        del os.environ["DENO_DIR"]+class TestDenoDir(DenoTestCase):+    def setUp(self):+        self.old_deno_dir = None+        if "DENO_DIR" in os.environ:

I think it's trying to reset the Deno_dir env after BUT I don't think this is respected in test.py. I haven't checked through the logic (this was mostly cut and paste)

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 # Runs the full test suite. # Usage: ./tools/test.py out/Debug import os+import subprocess import sys import unittest -from integration_tests import integration_tests-from deno_dir_test import deno_dir_test-from util import build_path, enable_ansi_colors, executable_suffix, run, rmtree-from util import run_output, tests_path, green_ok-from unit_tests import unit_tests-from util_test import util_test-from setup_test import setup_test-from benchmark_test import benchmark_test-from repl_test import repl_tests-from fetch_test import fetch_test-from fmt_test import fmt_test-import subprocess-import http_server---def check_exists(filename):-    if not os.path.exists(filename):-        print "Required target doesn't exist:", filename-        print "Run ./tools/build.py"-        sys.exit(1)---def test_no_color(deno_exe):-    sys.stdout.write("no_color test...")-    sys.stdout.flush()-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t], merge_env={"NO_COLOR": "1"})-    assert output.strip() == "noColor true"-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t])-    assert output.strip() == "noColor false"-    print green_ok()---def exec_path_test(deno_exe):-    cmd = [deno_exe, "run", "tests/exec_path.ts"]-    output = run_output(cmd)-    assert deno_exe in output.strip()+from benchmark_test import TestBenchmark+from deno_dir_test import TestDenoDir+from fetch_test import FetchTest+from fmt_test import FmtTest+from integration_tests import TestIntegrations+from repl_test import TestRepl+from setup_test import TestSetup+from unit_tests import JsUnitTests+from util_test import TestUtil++from is_tty_test import TestIsTty+# NOTE: These tests are skipped on Windows+from permission_prompt_test import permission_prompt_tests+from complex_permissions_test import complex_permissions_tests++from http_server import Spawn+from util import (DenoTestCase, ColorTextTestRunner, enable_ansi_colors,+                  executable_suffix, run, run_output, rmtree, tests_path,+                  test_args)+++class TestLib(DenoTestCase):+    @staticmethod+    def check_exists(filename):+        if not os.path.exists(filename):+            print "Required target doesn't exist:", filename+            print "Run ./tools/build.py"+            sys.exit(1)++    def test_executable_exists(self):+        self.check_exists(self.deno_exe)++    def _test(self, executable):+        "Test executable runs and exits with code 0."+        bin_file = os.path.join(self.build_dir, executable + executable_suffix)+        self.check_exists(bin_file)+        run([bin_file])++    def test_libdeno(self):+        self._test("libdeno_test")++    def test_cli(self):+        self._test("cli_test")++    def test_core(self):+        self._test("deno_core_test")++    def test_core_http_benchmark(self):+        self._test("deno_core_http_bench_test")++    def test_ts_library_builder(self):+        run([+            "node", "./node_modules/.bin/ts-node", "--project",+            "tools/ts_library_builder/tsconfig.json",+            "tools/ts_library_builder/test.ts"+        ])++    def test_no_color(self):+        t = os.path.join(tests_path, "no_color.js")+        output = run_output([self.deno_exe, "run", t],+                            merge_env={"NO_COLOR": "1"})+        assert output.strip() == "noColor true"+        t = os.path.join(tests_path, "no_color.js")+        output = run_output([self.deno_exe, "run", t])+        assert output.strip() == "noColor false"++    def test_exec_path(self):+        cmd = [self.deno_exe, "run", "tests/exec_path.ts"]+        output = run_output(cmd)+        assert self.deno_exe in output.strip()   def main(argv):-    if len(argv) == 2:-        build_dir = sys.argv[1]-    elif len(argv) == 1:-        build_dir = build_path()-    else:-        print "Usage: tools/test.py [build_dir]"-        sys.exit(1)--    deno_dir = os.path.join(build_dir, ".deno_test")+    args = test_args(argv)++    deno_dir = os.path.join(args.build_dir, ".deno_test")     if os.path.isdir(deno_dir):         rmtree(deno_dir)     os.environ["DENO_DIR"] = deno_dir      enable_ansi_colors() -    http_server.spawn()--    deno_exe = os.path.join(build_dir, "deno" + executable_suffix)-    check_exists(deno_exe)--    # Python/build tools testing-    setup_test()-    util_test()--    run([-        "node", "./node_modules/.bin/ts-node", "--project",-        "tools/ts_library_builder/tsconfig.json",-        "tools/ts_library_builder/test.ts"-    ])--    libdeno_test = os.path.join(build_dir, "libdeno_test" + executable_suffix)-    check_exists(libdeno_test)-    run([libdeno_test])--    cli_test = os.path.join(build_dir, "cli_test" + executable_suffix)-    check_exists(cli_test)-    run([cli_test])--    deno_core_test = os.path.join(build_dir,-                                  "deno_core_test" + executable_suffix)-    check_exists(deno_core_test)-    run([deno_core_test])--    deno_core_http_bench_test = os.path.join(-        build_dir, "deno_core_http_bench_test" + executable_suffix)-    check_exists(deno_core_http_bench_test)-    run([deno_core_http_bench_test])--    unit_tests(deno_exe)--    fetch_test(deno_exe)-    fmt_test(deno_exe)--    integration_tests(deno_exe)--    # TODO We currently skip testing the prompt and IsTTY in Windows completely.-    # Windows does not support the pty module used for testing the permission-    # prompt.-    if os.name != 'nt':-        from is_tty_test import is_tty_test-        from permission_prompt_test import permission_prompt_test-        from complex_permissions_test import complex_permissions_test-        permission_prompt_test(deno_exe)-        complex_permissions_test(deno_exe)-        is_tty_test(deno_exe)--    repl_tests(deno_exe)--    rmtree(deno_dir)--    deno_dir_test(deno_exe, deno_dir)--    test_no_color(deno_exe)--    benchmark_test(build_dir, deno_exe)-    exec_path_test(deno_exe)+    with Spawn():+        test_cases = [+            TestSetup,+            TestUtil,+            TestLib,+            JsUnitTests,+            FetchTest,+            FmtTest,+            TestIntegrations,+            TestRepl,+            TestDenoDir,+            TestBenchmark,+        ]+        if os.name != 'nt':+            test_cases.append(TestIsTty)+            test_cases += permission_prompt_tests()+            test_cases += complex_permissions_tests()++        suite = unittest.TestSuite([+            unittest.TestLoader().loadTestsFromTestCase(tc)+            for tc in test_cases+        ])++        result = ColorTextTestRunner(

I think I want to not call main in test_main, but rather do the module lookup there (unless suite is passed), I don't think this needs to be done yet. Benefit is simplified arg parsing (main parses args too).

hayd

comment created time in 2 months

issue commenthayd/deno_docker

Add information about DENO_DIR

Should we use /deno-dir/ over /cache/ ?

bartlomieju

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 # -*- coding: utf-8 -*- # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import os-import pty-import select import subprocess import sys import time import unittest -import http_server-from util import build_path, root_path, executable_suffix, green_ok, red_failed+from http_server import Spawn+from util import DenoTestCase, root_path, test_main, tty_capture  PERMISSIONS_PROMPT_TEST_TS = "tools/complex_permissions_test.ts"  PROMPT_PATTERN = b'⚠️' PERMISSION_DENIED_PATTERN = b'PermissionDenied: permission denied'  -# This function is copied from:-# https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e-# https://stackoverflow.com/q/52954248/1240268-def tty_capture(cmd, bytes_input, timeout=5):-    """Capture the output of cmd with bytes_input to stdin,-    with stdin, stdout and stderr as TTYs."""-    mo, so = pty.openpty()  # provide tty to enable line-buffering-    me, se = pty.openpty()-    mi, si = pty.openpty()-    fdmap = {mo: 'stdout', me: 'stderr', mi: 'stdin'}--    timeout_exact = time.time() + timeout-    p = subprocess.Popen(-        cmd, bufsize=1, stdin=si, stdout=so, stderr=se, close_fds=True)-    os.write(mi, bytes_input)--    select_timeout = .04  #seconds-    res = {'stdout': b'', 'stderr': b''}-    while True:-        ready, _, _ = select.select([mo, me], [], [], select_timeout)-        if ready:-            for fd in ready:-                data = os.read(fd, 512)-                if not data:-                    break-                res[fdmap[fd]] += data-        elif p.poll() is not None or time.time(-        ) > timeout_exact:  # select timed-out-            break  # p exited-    for fd in [si, so, se, mi, mo, me]:-        os.close(fd)  # can't do it sooner: it leads to errno.EIO error-    p.wait()-    return p.returncode, res['stdout'], res['stderr']---class ComplexPermissionTestCase(unittest.TestCase):-    def __init__(self, method_name, test_type, deno_exe):-        super(ComplexPermissionTestCase, self).__init__(method_name)-        self.test_type = test_type-        self.deno_exe = deno_exe-+@unittest.skipIf(os.name == 'nt', "Unable to test tty on Windows")+class BaseComplexPermissionTest(DenoTestCase):     def _run_deno(self, flags, args):         "Returns (return_code, stdout, stderr)."         cmd = ([self.deno_exe, "run", "--no-prompt"] + flags +                [PERMISSIONS_PROMPT_TEST_TS] + args)         return tty_capture(cmd, b'')  -class TestReadWritePermissions(ComplexPermissionTestCase):+class TestReadWritePermissions(BaseComplexPermissionTest):+    test_type = "read"

Good catch, I will investigate.

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 def mkdtemp():     # 'TS5009: Cannot find the common subdirectory path for the input files.'     temp_dir = os.environ["TEMP"] if os.name == 'nt' else None     return tempfile.mkdtemp(dir=temp_dir)+++class DenoTestCase(unittest.TestCase):+    @property+    def build_dir(self):+        args = test_args()+        return args.build_dir++    @property+    def deno_exe(self):+        return os.path.join(self.build_dir, "deno" + executable_suffix)+++# overload the test result class+class ColorTextTestResult(unittest.TextTestResult):+    def getDescription(self, test):+        name = str(test)+        if name.startswith("test_"):+            name = name[5:]+        return name++    def addSuccess(self, test):+        if self.showAll:+            self.stream.write(FG_GREEN)+        super(ColorTextTestResult, self).addSuccess(test)+        if self.showAll:+            self.stream.write(RESET)++    def addError(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addError(test, err)+        if self.showAll:+            self.stream.write(RESET)++    def addFailure(self, test, err):+        if self.showAll:+            self.stream.write(FG_RED)+        super(ColorTextTestResult, self).addFailure(test, err)+        if self.showAll:+            self.stream.write(RESET)+++class ColorTextTestRunner(unittest.TextTestRunner):+    resultclass = ColorTextTestResult+++def test_main():+    args = test_args()+    # FIXME(hayd) support more of the unittest.main API.+    return unittest.main(+        verbosity=2,

It can, @ry can we use dots by default and pass -v on Travis etc?

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 # Runs the full test suite. # Usage: ./tools/test.py out/Debug import os+import subprocess import sys import unittest -from integration_tests import integration_tests-from deno_dir_test import deno_dir_test-from util import build_path, enable_ansi_colors, executable_suffix, run, rmtree-from util import run_output, tests_path, green_ok-from unit_tests import unit_tests-from util_test import util_test-from setup_test import setup_test-from benchmark_test import benchmark_test-from repl_test import repl_tests-from fetch_test import fetch_test-from fmt_test import fmt_test-import subprocess-import http_server---def check_exists(filename):-    if not os.path.exists(filename):-        print "Required target doesn't exist:", filename-        print "Run ./tools/build.py"-        sys.exit(1)---def test_no_color(deno_exe):-    sys.stdout.write("no_color test...")-    sys.stdout.flush()-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t], merge_env={"NO_COLOR": "1"})-    assert output.strip() == "noColor true"-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t])-    assert output.strip() == "noColor false"-    print green_ok()---def exec_path_test(deno_exe):-    cmd = [deno_exe, "run", "tests/exec_path.ts"]-    output = run_output(cmd)-    assert deno_exe in output.strip()+from benchmark_test import TestBenchmark+from deno_dir_test import TestDenoDir+from fetch_test import FetchTest+from fmt_test import FmtTest+from integration_tests import TestIntegrations+from repl_test import TestRepl+from setup_test import TestSetup+from unit_tests import JsUnitTests+from util_test import TestUtil++from is_tty_test import TestIsTty+# NOTE: These tests are skipped on Windows+from permission_prompt_test import permission_prompt_tests+from complex_permissions_test import complex_permissions_tests++from http_server import Spawn+from util import (DenoTestCase, ColorTextTestRunner, enable_ansi_colors,+                  executable_suffix, run, run_output, rmtree, tests_path,+                  test_args)+++class TestLib(DenoTestCase):+    @staticmethod+    def check_exists(filename):+        if not os.path.exists(filename):+            print "Required target doesn't exist:", filename+            print "Run ./tools/build.py"+            sys.exit(1)++    def test_executable_exists(self):+        self.check_exists(self.deno_exe)++    def _test(self, executable):+        "Test executable runs and exits with code 0."+        bin_file = os.path.join(self.build_dir, executable + executable_suffix)+        self.check_exists(bin_file)+        run([bin_file])++    def test_libdeno(self):+        self._test("libdeno_test")++    def test_cli(self):+        self._test("cli_test")++    def test_core(self):+        self._test("deno_core_test")++    def test_core_http_benchmark(self):+        self._test("deno_core_http_bench_test")++    def test_ts_library_builder(self):+        run([+            "node", "./node_modules/.bin/ts-node", "--project",+            "tools/ts_library_builder/tsconfig.json",+            "tools/ts_library_builder/test.ts"+        ])++    def test_no_color(self):+        t = os.path.join(tests_path, "no_color.js")+        output = run_output([self.deno_exe, "run", t],+                            merge_env={"NO_COLOR": "1"})+        assert output.strip() == "noColor true"+        t = os.path.join(tests_path, "no_color.js")+        output = run_output([self.deno_exe, "run", t])+        assert output.strip() == "noColor false"++    def test_exec_path(self):+        cmd = [self.deno_exe, "run", "tests/exec_path.ts"]+        output = run_output(cmd)+        assert self.deno_exe in output.strip()   def main(argv):-    if len(argv) == 2:-        build_dir = sys.argv[1]-    elif len(argv) == 1:-        build_dir = build_path()-    else:-        print "Usage: tools/test.py [build_dir]"-        sys.exit(1)--    deno_dir = os.path.join(build_dir, ".deno_test")+    args = test_args(argv)++    deno_dir = os.path.join(args.build_dir, ".deno_test")     if os.path.isdir(deno_dir):         rmtree(deno_dir)     os.environ["DENO_DIR"] = deno_dir      enable_ansi_colors() -    http_server.spawn()--    deno_exe = os.path.join(build_dir, "deno" + executable_suffix)-    check_exists(deno_exe)--    # Python/build tools testing-    setup_test()-    util_test()--    run([-        "node", "./node_modules/.bin/ts-node", "--project",-        "tools/ts_library_builder/tsconfig.json",-        "tools/ts_library_builder/test.ts"-    ])--    libdeno_test = os.path.join(build_dir, "libdeno_test" + executable_suffix)-    check_exists(libdeno_test)-    run([libdeno_test])--    cli_test = os.path.join(build_dir, "cli_test" + executable_suffix)-    check_exists(cli_test)-    run([cli_test])--    deno_core_test = os.path.join(build_dir,-                                  "deno_core_test" + executable_suffix)-    check_exists(deno_core_test)-    run([deno_core_test])--    deno_core_http_bench_test = os.path.join(-        build_dir, "deno_core_http_bench_test" + executable_suffix)-    check_exists(deno_core_http_bench_test)-    run([deno_core_http_bench_test])--    unit_tests(deno_exe)--    fetch_test(deno_exe)-    fmt_test(deno_exe)--    integration_tests(deno_exe)--    # TODO We currently skip testing the prompt and IsTTY in Windows completely.-    # Windows does not support the pty module used for testing the permission-    # prompt.-    if os.name != 'nt':-        from is_tty_test import is_tty_test-        from permission_prompt_test import permission_prompt_test-        from complex_permissions_test import complex_permissions_test-        permission_prompt_test(deno_exe)-        complex_permissions_test(deno_exe)-        is_tty_test(deno_exe)--    repl_tests(deno_exe)--    rmtree(deno_dir)--    deno_dir_test(deno_exe, deno_dir)--    test_no_color(deno_exe)--    benchmark_test(build_dir, deno_exe)-    exec_path_test(deno_exe)+    with Spawn():+        test_cases = [+            TestSetup,+            TestUtil,+            TestLib,+            JsUnitTests,+            FetchTest,+            FmtTest,+            TestIntegrations,+            TestRepl,+            TestDenoDir,+            TestBenchmark,+        ]+        if os.name != 'nt':+            test_cases.append(TestIsTty)+            test_cases += permission_prompt_tests()+            test_cases += complex_permissions_tests()++        suite = unittest.TestSuite([+            unittest.TestLoader().loadTestsFromTestCase(tc)+            for tc in test_cases+        ])++        result = ColorTextTestRunner(

I'm not sure it looks up suite correctly, can you pass suite to main?

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 # Runs the full test suite. # Usage: ./tools/test.py out/Debug import os+import subprocess import sys import unittest -from integration_tests import integration_tests-from deno_dir_test import deno_dir_test-from util import build_path, enable_ansi_colors, executable_suffix, run, rmtree-from util import run_output, tests_path, green_ok-from unit_tests import unit_tests-from util_test import util_test-from setup_test import setup_test-from benchmark_test import benchmark_test-from repl_test import repl_tests-from fetch_test import fetch_test-from fmt_test import fmt_test-import subprocess-import http_server---def check_exists(filename):-    if not os.path.exists(filename):-        print "Required target doesn't exist:", filename-        print "Run ./tools/build.py"-        sys.exit(1)---def test_no_color(deno_exe):-    sys.stdout.write("no_color test...")-    sys.stdout.flush()-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t], merge_env={"NO_COLOR": "1"})-    assert output.strip() == "noColor true"-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t])-    assert output.strip() == "noColor false"-    print green_ok()---def exec_path_test(deno_exe):-    cmd = [deno_exe, "run", "tests/exec_path.ts"]-    output = run_output(cmd)-    assert deno_exe in output.strip()+from benchmark_test import TestBenchmark+from deno_dir_test import TestDenoDir+from fetch_test import FetchTest+from fmt_test import FmtTest+from integration_tests import TestIntegrations+from repl_test import TestRepl+from setup_test import TestSetup+from unit_tests import JsUnitTests+from util_test import TestUtil++from is_tty_test import TestIsTty+# NOTE: These tests are skipped on Windows+from permission_prompt_test import permission_prompt_tests+from complex_permissions_test import complex_permissions_tests++from http_server import Spawn+from util import (DenoTestCase, ColorTextTestRunner, enable_ansi_colors,+                  executable_suffix, run, run_output, rmtree, tests_path,+                  test_args)+++class TestLib(DenoTestCase):+    @staticmethod+    def check_exists(filename):+        if not os.path.exists(filename):+            print "Required target doesn't exist:", filename+            print "Run ./tools/build.py"+            sys.exit(1)++    def test_executable_exists(self):+        self.check_exists(self.deno_exe)++    def _test(self, executable):+        "Test executable runs and exits with code 0."+        bin_file = os.path.join(self.build_dir, executable + executable_suffix)+        self.check_exists(bin_file)+        run([bin_file])++    def test_libdeno(self):+        self._test("libdeno_test")++    def test_cli(self):+        self._test("cli_test")++    def test_core(self):+        self._test("deno_core_test")++    def test_core_http_benchmark(self):+        self._test("deno_core_http_bench_test")++    def test_ts_library_builder(self):+        run([+            "node", "./node_modules/.bin/ts-node", "--project",+            "tools/ts_library_builder/tsconfig.json",+            "tools/ts_library_builder/test.ts"+        ])++    def test_no_color(self):+        t = os.path.join(tests_path, "no_color.js")+        output = run_output([self.deno_exe, "run", t],+                            merge_env={"NO_COLOR": "1"})+        assert output.strip() == "noColor true"+        t = os.path.join(tests_path, "no_color.js")+        output = run_output([self.deno_exe, "run", t])+        assert output.strip() == "noColor false"++    def test_exec_path(self):+        cmd = [self.deno_exe, "run", "tests/exec_path.ts"]+        output = run_output(cmd)+        assert self.deno_exe in output.strip()   def main(argv):-    if len(argv) == 2:-        build_dir = sys.argv[1]-    elif len(argv) == 1:-        build_dir = build_path()-    else:-        print "Usage: tools/test.py [build_dir]"-        sys.exit(1)--    deno_dir = os.path.join(build_dir, ".deno_test")+    args = test_args(argv)++    deno_dir = os.path.join(args.build_dir, ".deno_test")     if os.path.isdir(deno_dir):         rmtree(deno_dir)     os.environ["DENO_DIR"] = deno_dir      enable_ansi_colors() -    http_server.spawn()--    deno_exe = os.path.join(build_dir, "deno" + executable_suffix)-    check_exists(deno_exe)--    # Python/build tools testing-    setup_test()-    util_test()--    run([-        "node", "./node_modules/.bin/ts-node", "--project",-        "tools/ts_library_builder/tsconfig.json",-        "tools/ts_library_builder/test.ts"-    ])--    libdeno_test = os.path.join(build_dir, "libdeno_test" + executable_suffix)-    check_exists(libdeno_test)-    run([libdeno_test])--    cli_test = os.path.join(build_dir, "cli_test" + executable_suffix)-    check_exists(cli_test)-    run([cli_test])--    deno_core_test = os.path.join(build_dir,-                                  "deno_core_test" + executable_suffix)-    check_exists(deno_core_test)-    run([deno_core_test])--    deno_core_http_bench_test = os.path.join(-        build_dir, "deno_core_http_bench_test" + executable_suffix)-    check_exists(deno_core_http_bench_test)-    run([deno_core_http_bench_test])--    unit_tests(deno_exe)--    fetch_test(deno_exe)-    fmt_test(deno_exe)--    integration_tests(deno_exe)--    # TODO We currently skip testing the prompt and IsTTY in Windows completely.-    # Windows does not support the pty module used for testing the permission-    # prompt.-    if os.name != 'nt':-        from is_tty_test import is_tty_test-        from permission_prompt_test import permission_prompt_test-        from complex_permissions_test import complex_permissions_test-        permission_prompt_test(deno_exe)-        complex_permissions_test(deno_exe)-        is_tty_test(deno_exe)--    repl_tests(deno_exe)--    rmtree(deno_dir)--    deno_dir_test(deno_exe, deno_dir)--    test_no_color(deno_exe)--    benchmark_test(build_dir, deno_exe)-    exec_path_test(deno_exe)+    with Spawn():+        test_cases = [+            TestSetup,+            TestUtil,+            TestLib,+            JsUnitTests,+            FetchTest,+            FmtTest,+            TestIntegrations,+            TestRepl,+            TestDenoDir,+            TestBenchmark,+        ]+        if os.name != 'nt':

Tests are very noisy with skip. But yes this is no longer necessary...

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 # Runs the full test suite. # Usage: ./tools/test.py out/Debug import os+import subprocess import sys import unittest -from integration_tests import integration_tests-from deno_dir_test import deno_dir_test-from util import build_path, enable_ansi_colors, executable_suffix, run, rmtree-from util import run_output, tests_path, green_ok-from unit_tests import unit_tests-from util_test import util_test-from setup_test import setup_test-from benchmark_test import benchmark_test-from repl_test import repl_tests-from fetch_test import fetch_test-from fmt_test import fmt_test-import subprocess-import http_server---def check_exists(filename):-    if not os.path.exists(filename):-        print "Required target doesn't exist:", filename-        print "Run ./tools/build.py"-        sys.exit(1)---def test_no_color(deno_exe):-    sys.stdout.write("no_color test...")-    sys.stdout.flush()-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t], merge_env={"NO_COLOR": "1"})-    assert output.strip() == "noColor true"-    t = os.path.join(tests_path, "no_color.js")-    output = run_output([deno_exe, "run", t])-    assert output.strip() == "noColor false"-    print green_ok()---def exec_path_test(deno_exe):-    cmd = [deno_exe, "run", "tests/exec_path.ts"]-    output = run_output(cmd)-    assert deno_exe in output.strip()+from benchmark_test import TestBenchmark+from deno_dir_test import TestDenoDir+from fetch_test import FetchTest+from fmt_test import FmtTest+from integration_tests import TestIntegrations+from repl_test import TestRepl+from setup_test import TestSetup+from unit_tests import JsUnitTests+from util_test import TestUtil++from is_tty_test import TestIsTty+# NOTE: These tests are skipped on Windows+from permission_prompt_test import permission_prompt_tests+from complex_permissions_test import complex_permissions_tests++from http_server import Spawn+from util import (DenoTestCase, ColorTextTestRunner, enable_ansi_colors,+                  executable_suffix, run, run_output, rmtree, tests_path,+                  test_args)+++class TestLib(DenoTestCase):

Should this be split up further? In a separate files?

hayd

comment created time in 2 months

Pull request review commentdenoland/deno

chore: refactor python tests to use unittest

 def integration_tests(deno_exe, test_filter=None):             actual_out = e.output          if exit_code != actual_code:-            print "... " + red_failed()             print "Expected exit code %d but got %d" % (exit_code, actual_code)             print "Output:"             print actual_out-            sys.exit(1)+            raise AssertionError()          actual_out = strip_ansi_codes(actual_out)          if pattern_match(expected_out, actual_out) != True:-            print red_failed()             print "Expected output does not match actual."             print "Expected output: \n" + expected_out             print "Actual output:   \n" + actual_out-            sys.exit(1)+            # FIXME use unittest assertions+            raise AssertionError()

I'll replace this with assertEqual, which will print the above lines.

hayd

comment created time in 2 months

issue commenthayd/deno_docker

Add information about DENO_DIR

It can be overwritten by the user.

bartlomieju

comment created time in 2 months

more