Browse Source

Fix test

content-update
Xavier Petit 4 years ago
parent
commit
ad8185a189
No known key found for this signature in database
GPG Key ID: CA3F2B17E25ABD26
  1. 53
      go/tests/prog/ztail_test/main.go

53
go/tests/prog/ztail_test/main.go

@ -1,36 +1,29 @@
package main
// Compares only the stdout of each program
// As long as the program executes like tail for the stdout
// and the error messages are send to stderr
// the program passes the test
import (
"io/ioutil"
"os"
"lib"
)
func main() {
argArr := [][]string{
{"-c", "23", "student/ztail/main.go"},
{"-c", "23", "student/ztail/README.md", "fjksdsf"},
{"-c", "23", "../../README.md", "fjksdsf", "-c", "43"},
{"student/ztail/main.go", "-c", "23"},
{"-c", "jfdka", "23"},
file1 := "quest8.txt"
file2 := "quest8T.txt"
if err := ioutil.WriteFile(file1, []byte(lib.RandWords()+"\n"), os.ModePerm); err != nil {
panic(err)
}
if err := ioutil.WriteFile(file2, []byte(lib.RandWords()+"\n"), os.ModePerm); err != nil {
panic(err)
}
for _, args := range argArr {
_ = args
// b, errC := exec.Command("tail", args...).CombinedOutput()
// correct := string(b)
// b, err := exec.Command
// out, err := lib.MainOut("student/ztail", args...)
// if out != correct {
// lib.Fatalf("./ztail \"%s\" prints %q instead of %q\n",
// strings.Join(args, " "), out, correct)
// }
// if errC != nil && err == nil {
// lib.Fatalf("./ztail \"%s\" prints %q instead of %q\n", strings.Join(args, " "), "", errC)
// }
// if err != nil && errC != nil && err != errC.Error() {
// lib.Fatalf("./ztail %s prints %q instead of %q\n", strings.Join(args, " "), err, errC)
// }
table := [][]string{
{"-c", "23", "src/student/ztail/main.go", file1},
{"-c", "13", "src/student/ztail/main.go", "fjksdsf", file2},
{"-c", "5", file1, file2},
{"-c", "1", "fjksdsf"},
{"-c", "1", file1, file2},
}
for _, args := range table {
lib.ChallengeMain("ztail", args...)
}
}
// TODO:
// never use programs we didn't wrote (do not run the true cat but instead code our own solution)
// to be fixed

Loading…
Cancel
Save