Browse Source

Fix test

pull/644/head
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 package main
// Compares only the stdout of each program import (
// As long as the program executes like tail for the stdout "io/ioutil"
// and the error messages are send to stderr "os"
// the program passes the test
"lib"
)
func main() { func main() {
argArr := [][]string{ file1 := "quest8.txt"
{"-c", "23", "student/ztail/main.go"}, file2 := "quest8T.txt"
{"-c", "23", "student/ztail/README.md", "fjksdsf"}, if err := ioutil.WriteFile(file1, []byte(lib.RandWords()+"\n"), os.ModePerm); err != nil {
{"-c", "23", "../../README.md", "fjksdsf", "-c", "43"}, panic(err)
{"student/ztail/main.go", "-c", "23"}, }
{"-c", "jfdka", "23"}, if err := ioutil.WriteFile(file2, []byte(lib.RandWords()+"\n"), os.ModePerm); err != nil {
panic(err)
} }
for _, args := range argArr { table := [][]string{
_ = args {"-c", "23", "src/student/ztail/main.go", file1},
// b, errC := exec.Command("tail", args...).CombinedOutput() {"-c", "13", "src/student/ztail/main.go", "fjksdsf", file2},
// correct := string(b) {"-c", "5", file1, file2},
// b, err := exec.Command {"-c", "1", "fjksdsf"},
// out, err := lib.MainOut("student/ztail", args...) {"-c", "1", file1, file2},
// if out != correct { }
// lib.Fatalf("./ztail \"%s\" prints %q instead of %q\n", for _, args := range table {
// strings.Join(args, " "), out, correct) lib.ChallengeMain("ztail", args...)
// }
// 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)
// }
} }
} }
// 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