8000 [util][testutil] Add NO_IDE env check to skip check only runs in IDE · Issue #91 · dyweb/gommon · GitHub
[go: up one dir, main page]

Skip to content
  • [util][testutil] Add NO_IDE env check to skip check only runs in IDE #91

    Open

    Description

    @at15

    There are many ad-hoc unit tests that can only run in IDE (due to config, exec order etc.) and need to be skipped if the test is run in CI or just through makefile

    Then in package's TestMain we can call TestPkg to enable/disable entire package, and if just a single func we can use tesutil.SkipIf(testutil.EnvTrue("NO_IDE"))

    func TestPkg(pkg string) bool {
    	pkgLock.Lock()
    	defer pkgLock.Unlock()
    
    	noIDE := os.Getenv("NO_IDE")
    	if noIDE == "true" {
    		log.Printf("test package %s is skipped, set NO_IDE=false to enable it, currently NO_IDE=%s", pkg, noIDE)
    		return false
    	}
    }

    in Makefile

    GO = CGO_ENABLED=0 go
    # NO_IDE is used to skip test or packages that are meant to run in IDE manually due to hard coded config
    GOTEST = NO_IDE=true $(GO) test
    
    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

      • 0