Skip to content

nodejs_test seems to be ignoring the timeout attribute #733

Closed

Description

@lambertjamesd

nodejs_test seems to be ignoring the timeout input and defaults to moderate with a 5 minute timeout

  
nodejs_test(
    name="test",
    data = [
        "//example:test.js",
    ],
    entry_point = "broken_timeout/example/test.js",
    timeout="short",
)
  

test.js

  
console.log('doing the test');

setTimeout(() => process.exit(0), 120 * 1000);
  

When I run this test it should timeout after a minute but instead is passes after two minutes

  
bazel test //example:test
INFO: Analysed target //example:test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //example:test up-to-date:
  bazel-bin/example/test_bin.sh
  bazel-bin/example/test
INFO: Elapsed time: 121.168s, Critical Path: 120.88s
INFO: 2 processes: 2 linux-sandbox.
INFO: Build completed successfully, 2 total actions
//example:test                                                           PASSED in 120.4s

INFO: Build completed successfully, 2 total actions
  

Here is a zip file containing a simple bazel project demonstrating the problem
broken_timeout_example.zip

Operating System:

  
Ubuntu 18.04.2 LTS
  

Output of bazel version:

  
bazel version
Build label: 0.24.1.1
Build target: bazel-out/k8-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Apr 5 22:38:01 2019 (1554503881)
Build timestamp: 1554503881
  

Rules version (SHA):

  
1f6d878a9ea3a095291f66e3d1a0f6b4641f5159
  

Activity

  1. alexeagle commented on May 24, 2019

    @alexeagle
    Collaborator

    It's another sad consequence of using macros.

    in //:defs.bzl we have

    load(
        "//internal/node:node.bzl",
        _nodejs_binary = "nodejs_binary_macro",
        _nodejs_test = "nodejs_test_macro",
    )
    nodejs_test = _nodejs_test
    

    which means that a nodejs_test rule is defined by the macro in internal/node/node.bzl

    def nodejs_test_macro(name, data = [], args = [], visibility = None, tags = [], **kwargs):
        all_data = data + ["@bazel_tools//tools/bash/runfiles"]
    
        nodejs_test(
            name = "%s_bin" % name,
            data = all_data,
            testonly = 1,
            tags = ["manual"],
            **kwargs
        )
    
        native.sh_test(
            name = name,
            args = args,
            tags = tags,
            visibility = visibility,
            srcs = [":%s_bin.sh" % name],
            data = [":%s_bin" % name],
        )
    

    One major problem with macros is it's not clear which arguments to the macro get passed as attributes to the two underlying rules. This bug is because timeout is in the residual **kwargs which is passed to nodejs_test but not to the native sh_test.

    Anyway this macro causes a bash dependency which we don't want either. This is another consequence of #51

    Let me take a stab at removing the macros and see if we can get things to continue working on Windows...

  2. added a commit that references this issue on May 24, 2019
    36a541f
  3. added 3 commits that reference this issue on Aug 5, 2019
    194c712
    3fe62de
    cec693e
  4. alexeagle commented on Sep 6, 2019

    @alexeagle
    Collaborator

    Fixed by #1078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions