Delve: [doc request] How to pass command line arguments to dlv test ?

Created on 27 Jan 2017  路  2Comments  路  Source: go-delve/delve

  1. What version of Delve are you using (dlv version)?
[vagrant@k8s-env cmd]$ dlv version
Delve Debugger
Version: 0.11.0-alpha
Build:
  1. What version of Go are you using? (go version)?
[vagrant@k8s-env cmd]$ go version
go version go1.7.4 linux/amd64
  1. What operating system and processor architecture are you using?
[vagrant@k8s-env cmd]$ uname -a
Linux k8s-env 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  1. What did you do?

Attempted to pass command line arguments to dlv test

  1. What did you expect to see?

A go test like behavior for the passed command line arguments.

  1. What did you see instead?

Complaint about unknown command line arguments.

What is the way to pass command line arguments to dlv test ?

For example I would like to pass -run=<TestFuncName> to go test in order to narrow down the test run .

I have found https://github.com/derekparker/delve/issues/126 and https://github.com/derekparker/delve/issues/178 but they do not mention the dlv test command.

This is an example of what I have tried.
The -run=TestApplyObject works for go test but does not work with dlv test --

[vagrant@k8s-env cmd]$ go  test  -run=TestApplyObject
PASS
ok      k8s.io/kubernetes/pkg/kubectl/cmd   0.032s
[vagrant@k8s-env cmd]$ dlv  test  --  -run=TestApplyObject
Type 'help' for list of commands.
(dlv) c
flag provided but not defined: -run
Usage of ./debug.test:
  -alsologtostderr
        log to standard error as well as files
  -httptest.serve string
        if non-empty, httptest.NewServer serves on this address and blocks
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace
  -log_dir string
        If non-empty, write log files in this directory
  -logtostderr
        log to standard error instead of files
  -stderrthreshold value
        logs at or above this threshold go to stderr
  -test.bench string
        regular expression per path component to select benchmarks to run
  -test.benchmem
        print memory allocations for benchmarks
  -test.benchtime duration
        approximate run time for each benchmark (default 1s)
  -test.blockprofile string
        write a goroutine blocking profile to the named file after execution
  -test.blockprofilerate int
        if >= 0, calls runtime.SetBlockProfileRate() (default 1)
  -test.count n
        run tests and benchmarks n times (default 1)
  -test.coverprofile string
        write a coverage profile to the named file after execution
  -test.cpu string
        comma-separated list of number of CPUs to use for each test
  -test.cpuprofile string
        write a cpu profile to the named file during execution
  -test.memprofile string
        write a memory profile to the named file after execution
  -test.memprofilerate int
        if >=0, sets runtime.MemProfileRate
  -test.outputdir string
        directory in which to write profiles
  -test.parallel int
        maximum test parallelism (default 2)
  -test.run string
        regular expression to select tests and examples to run
  -test.short
        run smaller test suite to save time
  -test.timeout duration
        if positive, sets an aggregate time limit for all tests
  -test.trace string
        write an execution trace to the named file after execution
  -test.v
        verbose: print additional output
  -v value
        log level for V logs
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging
Process 6379 has exited with status 2
(dlv)

I could add a break point to TestApplyObject test and then continue my debugging only after that breakpoint hits. That is one workaround I use for now.

Most helpful comment

Ahhh !
It was in front of me.

The usage text from dlv test mentions the correct command line param.

This works for me

 dlv  test  --  -test.run=TestApplyObject

All 2 comments

Ahhh !
It was in front of me.

The usage text from dlv test mentions the correct command line param.

This works for me

 dlv  test  --  -test.run=TestApplyObject

I need 3 parameters
autotest -all -w ./
but, this dlv debug autotest/main.go -- -all=true -w=true -template_dir="./" dosn't work, why ?

Was this page helpful?
0 / 5 - 0 ratings