Skip to content

Commit

Permalink
Merge pull request #33 from k1LoW/fix-test-too-many-tables-with-ulimi…
Browse files Browse the repository at this point in the history
…t-256

Fix `too many open files`
  • Loading branch information
k1LoW authored Jul 9, 2018
2 parents 2668fd4 + 92fd3c1 commit 6e717a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ testdoc: build
test_too_many_tables: build
usql pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable -f test/createdb_too_many.sql
usql pg://postgres:pgpass@localhost:55432/too_many?sslmode=disable -f test/createtable_too_many.sql
./tbls doc pg://postgres:pgpass@localhost:55432/too_many?sslmode=disable -f /tmp
./tbls diff pg://postgres:pgpass@localhost:55432/too_many?sslmode=disable /tmp
ulimit -n 256 && ./tbls doc pg://postgres:pgpass@localhost:55432/too_many?sslmode=disable -f /tmp
ulimit -n 256 && ./tbls diff pg://postgres:pgpass@localhost:55432/too_many?sslmode=disable /tmp

build: template
go build -ldflags="$(BUILD_LDFLAGS)"
Expand Down
12 changes: 6 additions & 6 deletions output/dot/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ var _Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26 = "digraph \"{{ .Table.Name

// Assets returns go-assets FileSystem
var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"schema.dot.tmpl", "table.dot.tmpl"}}, map[string]*assets.File{
"/table.dot.tmpl": &assets.File{
Path: "/table.dot.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1530370605, 1530370605000000000),
Data: []byte(_Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26),
}, "/": &assets.File{
"/": &assets.File{
Path: "/",
FileMode: 0x800001ed,
Mtime: time.Unix(1530370605, 1530370605000000000),
Expand All @@ -26,4 +21,9 @@ var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"schema.dot.
FileMode: 0x1a4,
Mtime: time.Unix(1530370605, 1530370605000000000),
Data: []byte(_Assets21532ae17ad95976ac467eeaeab81f2bb1d537e4),
}, "/table.dot.tmpl": &assets.File{
Path: "/table.dot.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1530370605, 1530370605000000000),
Data: []byte(_Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26),
}}, "")
5 changes: 4 additions & 1 deletion output/md/md.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ func Output(s *schema.Schema, path string, force bool) error {
// tables
for _, t := range s.Tables {
file, err := os.Create(filepath.Join(fullPath, fmt.Sprintf("%s.md", t.Name)))
defer file.Close()
if err != nil {
file.Close()
return err
}
f, _ := Assets.Open(filepath.Join("/", "table.md.tmpl"))
bs, _ := ioutil.ReadAll(f)
tmpl, err := template.New(t.Name).Parse(string(bs))
if err != nil {
file.Close()
return err
}
er := false
Expand All @@ -70,9 +71,11 @@ func Output(s *schema.Schema, path string, force bool) error {
"er": er,
})
if err != nil {
file.Close()
return err
}
fmt.Printf("%s\n", filepath.Join(path, fmt.Sprintf("%s.md", t.Name)))
file.Close()
}
return nil
}
Expand Down

0 comments on commit 6e717a2

Please sign in to comment.