mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
Maintenance: batch of minor changes (#183)
* exclude build artifacts from git * build: simplify building by using src-d/ci * bench: simplify&fix shell runners * build: simplify benchmarks* targets * test: remove dependency on single test suite * doc: rel image link + linguist cli difference highlight * suggestions from code review * bench: add fail fast to all shell runners Signed-off-by: Alexander Bezzubov <bzz@apache.org>
This commit is contained in:
parent
84b9e638a4
commit
ef50154395
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,4 +4,6 @@ benchmarks/output
|
||||
Makefile.main
|
||||
.shared
|
||||
.idea
|
||||
.docsrv-resources
|
||||
.docsrv-resources
|
||||
build/
|
||||
java/lib/
|
||||
|
26
Makefile
26
Makefile
@ -23,12 +23,6 @@ $(DOCS_PATH)/Makefile.inc:
|
||||
|
||||
LINGUIST_PATH = .linguist
|
||||
|
||||
# build CLI
|
||||
LOCAL_TAG := $(shell git describe --tags --abbrev=0)
|
||||
LOCAL_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
LOCAL_BUILD := $(shell date +"%m-%d-%Y_%H_%M_%S")
|
||||
LOCAL_LDFLAGS = -s -X main.version=$(LOCAL_TAG) -X main.build=$(LOCAL_BUILD) -X main.commit=$(LOCAL_COMMIT)
|
||||
|
||||
# shared objects
|
||||
RESOURCES_DIR=./.shared
|
||||
LINUX_DIR=$(RESOURCES_DIR)/linux-x86-64
|
||||
@ -50,21 +44,21 @@ clean-shared:
|
||||
clean: clean-linguist clean-shared
|
||||
|
||||
code-generate: $(LINGUIST_PATH)
|
||||
mkdir -p data
|
||||
mkdir -p data && \
|
||||
go run internal/code-generator/main.go
|
||||
|
||||
benchmarks: $(LINGUIST_PATH)
|
||||
go test -run=NONE -bench=. && benchmarks/linguist-total.sh
|
||||
go test -run=NONE -bench=. && \
|
||||
benchmarks/linguist-total.rb
|
||||
|
||||
benchmarks-samples: $(LINGUIST_PATH)
|
||||
go test -run=NONE -bench=. -benchtime=5us && benchmarks/linguist-samples.rb
|
||||
go test -run=NONE -bench=. -benchtime=5us && \
|
||||
benchmarks/linguist-samples.rb
|
||||
|
||||
benchmarks-slow: $(LINGUST_PATH)
|
||||
mkdir -p benchmarks/output && go test -run=NONE -bench=. -slow -benchtime=100ms -timeout=100h >benchmarks/output/enry_samples.bench && \
|
||||
benchmarks/linguist-samples.rb 5 >benchmarks/output/linguist_samples.bench
|
||||
|
||||
build-cli:
|
||||
go build -o enry -ldflags "$(LOCAL_LDFLAGS)" cmd/enry/main.go
|
||||
benchmarks-slow: $(LINGUIST_PATH)
|
||||
mkdir -p benchmarks/output && \
|
||||
go test -run=NONE -bench=. -slow -benchtime=100ms -timeout=100h > benchmarks/output/enry_samples.bench && \
|
||||
benchmarks/linguist-samples.rb 5 > benchmarks/output/linguist_samples.bench
|
||||
|
||||
linux-shared: $(LINUX_SHARED_LIB)
|
||||
|
||||
@ -79,3 +73,5 @@ $(LINUX_SHARED_LIB):
|
||||
mkdir -p $(LINUX_DIR) && \
|
||||
GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -o $(LINUX_SHARED_LIB) $(NATIVE_LIB) && \
|
||||
mv $(LINUX_DIR)/$(HEADER_FILE) $(RESOURCES_DIR)/$(HEADER_FILE)
|
||||
|
||||
.PHONY: benchmarks benchmarks-samples benchmarks-slow
|
||||
|
@ -14,7 +14,7 @@ go get gopkg.in/src-d/enry.v1/...
|
||||
|
||||
To build enry's CLI you must run
|
||||
|
||||
make build-cli
|
||||
make build
|
||||
|
||||
this will generate a binary in the project's root directory called `enry`. You can then move this binary to anywhere in your `PATH`.
|
||||
|
||||
@ -195,6 +195,7 @@ expression](https://github.com/github/linguist/blob/master/lib/linguist/heuristi
|
||||
for `*.sql` files right. This expression doesn't comply with the pattern for the
|
||||
rest in [heuristics.rb](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb).
|
||||
|
||||
`enry` [CLI tool](#cli) does not require a full Git repository to be present in filesystem in order to report languages.
|
||||
|
||||
Benchmarks
|
||||
------------
|
||||
@ -203,7 +204,7 @@ Enry's language detection has been compared with Linguist's one. In order to do
|
||||
|
||||
We got these results:
|
||||
|
||||
![histogram](https://raw.githubusercontent.com/src-d/enry/master/benchmarks/histogram/distribution.png)
|
||||
![histogram](benchmarks/histogram/distribution.png)
|
||||
|
||||
The histogram represents the number of files for which spent time in language
|
||||
detection was in the range of the time interval indicated in the x axis.
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd benchmarks/output && go run ../parser/main.go -outdir ../csv && \
|
||||
cd ../csv && go run ../parser/main.go -distribution
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
cd benchmarks/output
|
||||
go run ../parser/main.go -outdir ../csv
|
||||
cd ../csv
|
||||
go run ../parser/main.go -distribution
|
||||
|
@ -1,4 +1,6 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
mkdir -p benchmarks/output && go test -run NONE -bench=. -benchtime=120s -timeout=100h >benchmarks/output/enry_total.bench && \
|
||||
benchmarks/linguist-total.rb 5 >benchmarks/output/linguist_total.bench
|
||||
mkdir -p benchmarks/output
|
||||
go test -run NONE -bench=. -benchtime=120s -timeout=100h > benchmarks/output/enry_total.bench
|
||||
benchmarks/linguist-total.rb 5 > benchmarks/output/linguist_total.bench
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
benchmarks/run-benchmarks.sh && make benchmarks-slow && \
|
||||
benchmarks/parse.sh && benchmarks/plot-histogram.gp
|
||||
benchmarks/run-benchmarks.sh
|
||||
make benchmarks-slow
|
||||
benchmarks/parse.sh
|
||||
benchmarks/plot-histogram.gp
|
||||
|
@ -24,7 +24,7 @@ type EnryTestSuite struct {
|
||||
cloned bool
|
||||
}
|
||||
|
||||
func TestEnryTestSuite(t *testing.T) {
|
||||
func Test_EnryTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(EnryTestSuite))
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func (s *EnryTestSuite) TestIsAuxiliaryLanguage() {
|
||||
func TestIsAuxiliaryLanguage(t *testing.T) {
|
||||
type testType struct {
|
||||
name string
|
||||
lang string
|
||||
@ -30,11 +30,12 @@ func (s *EnryTestSuite) TestIsAuxiliaryLanguage() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsAuxiliaryLanguage(test.lang)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected,
|
||||
fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsVendor() {
|
||||
func TestIsVendor(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@ -53,11 +54,11 @@ func (s *EnryTestSuite) TestIsVendor() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsVendor(test.path)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsDocumentation() {
|
||||
func TestIsDocumentation(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@ -69,11 +70,11 @@ func (s *EnryTestSuite) TestIsDocumentation() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsDocumentation(test.path)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsImage() {
|
||||
func TestIsImage(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@ -88,11 +89,11 @@ func (s *EnryTestSuite) TestIsImage() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsImage(test.path)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestGetMimeType() {
|
||||
func TestGetMimeType(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@ -106,11 +107,11 @@ func (s *EnryTestSuite) TestGetMimeType() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := GetMimeType(test.path, test.lang)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsConfiguration() {
|
||||
func TestIsConfiguration(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@ -123,11 +124,11 @@ func (s *EnryTestSuite) TestIsConfiguration() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsConfiguration(test.path)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsBinary() {
|
||||
func TestIsBinary(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
data []byte
|
||||
@ -140,11 +141,11 @@ func (s *EnryTestSuite) TestIsBinary() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsBinary(test.data)
|
||||
assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsDotFile() {
|
||||
func TestIsDotFile(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
@ -156,7 +157,7 @@ func (s *EnryTestSuite) TestIsDotFile() {
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsDotFile(test.path)
|
||||
assert.Equal(s.T(), test.expected, is, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
assert.Equal(t, test.expected, is, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user