Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using flags with core causes testing flags to be parsed. #631

Closed
travisperson opened this issue Jan 24, 2015 · 2 comments
Closed

Using flags with core causes testing flags to be parsed. #631

travisperson opened this issue Jan 24, 2015 · 2 comments
Labels
kind/bug A bug in existing code (including security flaws) topic/cleanup Topic cleanup

Comments

@travisperson
Copy link
Member

Including the core import and using the flag import causes the testing imports flags to be included in parsing.

Output

~/s/g/t/tmp $ ./main -h
Usage of ./main:
  -flag=10: A flag
  -test.bench="": regular expression to select benchmarks to run
  -test.benchmem=false: print memory allocations for benchmarks
  -test.benchtime=1s: approximate run time for each benchmark
  -test.blockprofile="": write a goroutine blocking profile to the named file after execution
  -test.blockprofilerate=1: if >= 0, calls runtime.SetBlockProfileRate()
  -test.coverprofile="": write a coverage profile to the named file after execution
  -test.cpu="": comma-separated list of number of CPUs to use for each test
  -test.cpuprofile="": write a cpu profile to the named file during execution
  -test.memprofile="": write a memory profile to the named file after execution
  -test.memprofilerate=0: if >=0, sets runtime.MemProfileRate
  -test.outputdir="": directory in which to write profiles
  -test.parallel=1: maximum test parallelism
  -test.run="": regular expression to select tests and examples to run
  -test.short=false: run smaller test suite to save time
  -test.timeout=0: if positive, sets an aggregate time limit for all tests
  -test.v=false: verbose: print additional output
~/s/g/t/tmp $ 

Expected output

~/s/g/t/tmp $ ./main -h
Usage of ./main:
  -flag=10: A flag

Repo

package main

import (
    core "github.com/jbenet/go-ipfs/core"
    "flag"
    "fmt"
)

func main() {
    fake_flag := flag.Int("flag", 10, "A flag")

    flag.Parse()

    node,_ := core.NewMockNode()

    fmt.Println(*fake_flag)
    fmt.Println(node)
}

As you can see the NewMockNode is included in the core package. This function uses the util/testutil which includes testing.

It would appear that the mock.go file should be mock_test.go as NewMockNode is only used in fuse/ipns/ipns_test.go.

@jbenet
Copy link
Member

jbenet commented Jan 24, 2015

Thanks for catching this! #637

@jbenet jbenet added topic/cleanup Topic cleanup kind/bug A bug in existing code (including security flaws) labels Mar 28, 2015
@whyrusleeping
Copy link
Member

resolved

@Stebalien Stebalien mentioned this issue May 26, 2020
77 tasks
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this issue Oct 23, 2021
…s#631)

* Bootstrap when RT is empty and optimize allocations.

Co-authored-by: Steven Allen <steven@stebalien.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) topic/cleanup Topic cleanup
Projects
None yet
Development

No branches or pull requests

3 participants