unitTestOverheadRemover

command
v0.0.0-...-4f0a3a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Example

This tool removes the advocate overhead for a testfile. It does so by looking through every line and if it finds the advocate import or preamble somwhere skips them.

Input

This script takes 2 arguments.

  • -f: Filepath to the testfile
  • -t: Testname

Output

The output is the adjusted file with the same name the original

Usage

Given a file some_test.go you can use the script like so

go run unitTestOverheadRemover.go -f <path-to-some_test.go> -t <test-name>
Example

Given a file file.go

package main

import (
    "testing"
    "advocate"
    "fmt"
    "time"
)

func TestSomething(t *testing.T) {
	// ======= Preamble Start =======
		advocate.InitTracing(0)
		defer advocate.Finish()
	// ======= Preamble End =======
	c := make(chan int, 0)

	go func() {
		c <- 1
	}()

	go func() {
		<-c
	}()

	time.Sleep(10 * time.Millisecond)
	close(c)
}

After the script ran over the file it will look like:

package main

import (
    "testing"
    "fmt"
    "time"
)

func TestSomething(t *testing.T) {
	c := make(chan int, 0)

	go func() {
		c <- 1
	}()

	go func() {
		<-c
	}()

	time.Sleep(10 * time.Millisecond)
	close(c)
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL