Skip to content
Snippets Groups Projects
Verified Commit 298aa3c8 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

oof

parent 2cfa948f
Branches
Tags 5.2.5
No related merge requests found
Pipeline #6801 passed
......@@ -2,11 +2,12 @@ package main
import (
"git.sch.bme.hu/insert-epic-projlab-team-name-here/tooling/plab/helpers"
"git.sch.bme.hu/insert-epic-projlab-team-name-here/tooling/plab/tests"
"os"
)
func main() {
mainCmds := helpers.CmdFrom(os.Args[0], "go projlab tool", Timetable, Javadoc, Classdiag, Check)
mainCmds := helpers.CmdFrom(os.Args[0], "go projlab tool", Timetable, Javadoc, Classdiag, Check, tests.TestsToLatex)
if len(os.Args) < 2 {
os.Args = append(os.Args, "help")
}
......
package tests
import (
"fmt"
"io"
"os"
"os/exec"
)
func runTest(name string) error {
fmt.Println(name)
cmd := exec.Command("java", "-jar", "../src/projlab.jar")
file, err := os.Open(name)
if err != nil {
return err
}
stdin, err := cmd.StdinPipe()
if err != nil {
return err
}
_, err = io.Copy(stdin, file)
if err != nil {
return err
}
err = stdin.Close()
if err != nil {
return err
}
b, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(string(b))
}
return err
}
package tests
import (
"bytes"
"fmt"
"git.sch.bme.hu/insert-epic-projlab-team-name-here/tooling/plab/helpers"
"io/ioutil"
"os"
"os/exec"
"strings"
)
var TestsToLatex = helpers.Subcommand{
Name: "testtolatex",
Command: func(args []string) {
const dir = "../tests/"
tests, e := ioutil.ReadDir(dir)
if e != nil {
panic(e)
}
var buf bytes.Buffer
for _, t := range tests {
e := runTest(dir + t.Name())
if e != nil {
panic(e)
}
e = plantumlToLatex()
if e != nil {
panic(e)
}
b, e := ioutil.ReadFile("../seq.latex")
buf.WriteString("\\subsubsection{")
testname := ""
tmp := strings.Split(t.Name(), ".")
for i, part := range tmp {
if i < len(tmp)-1 {
testname += part
}
if i < len(tmp)-2 {
testname += "."
}
}
buf.WriteString(testname)
buf.WriteString("}\n")
buf.WriteString(`
\begin{figure}[H]
\begin{center}
\resizebox*{!}{\textheight-2cm}{`)
buf.Write(b)
buf.WriteString(`
}
\end{center}
\end{figure}
`)
buf.WriteString("\n\\newpage\n")
}
e = ioutil.WriteFile("/tmp/testseq.latex", buf.Bytes(), os.ModePerm)
if e != nil {
panic(e)
}
},
Help: "gen seq from test into latex",
}
func plantumlToLatex() error {
b, e := exec.Command("plantuml", "-tlatex:nopreamble", "../seq.puml").CombinedOutput()
if e != nil {
fmt.Println(string(b))
return e
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment