Skip to content

Commit

Permalink
test: bug #130 reproduced (Go tests are supposed to fail) #129 #130
Browse files Browse the repository at this point in the history
  • Loading branch information
flelli committed Jan 22, 2023
1 parent b380d95 commit 8477ff3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/go/nyx/git/go_git_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func (r goGitRepository) IsClean() (bool, error) {
// if the output is the empty string the repository is clean
if "" == strings.TrimSpace(out.String()) {
log.Debugf("workaround #130: the 'git status' command returned an empty output so the repository is clean")
clean = true
//clean = true
} else {
log.Debugf("workaround #130: the 'git status' command returned a non-empty output so the repository is dirty")
clean = false
Expand Down
6 changes: 3 additions & 3 deletions modules/go/nyx/test/integration/git/go_git_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t
cmd := &exec.Cmd{Path: commandPath, Dir: testDirectory, Env: os.Environ(), Args: []string{"git", "init", "testrepo"}, Stdout: out, Stderr: out}
err = cmd.Run()
if err != nil {
fmt.Printf("command '%v' resulted in an error and its output is:\n", cmd.String())
fmt.Printf("output from '%v' is:\n", cmd.String())
fmt.Printf("%v\n", out.String())
}
assert.NoError(t, err)
Expand Down Expand Up @@ -1500,7 +1500,7 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t
cmd = &exec.Cmd{Path: commandPath, Dir: repoDirectory, Env: os.Environ(), Args: []string{"git", "add", "."}, Stdout: out, Stderr: out}
err = cmd.Run()
if err != nil {
fmt.Printf("command '%v' resulted in an error and its output is:\n", cmd.String())
fmt.Printf("output from '%v' is:\n", cmd.String())
fmt.Printf("%v\n", out.String())
}
assert.NoError(t, err)
Expand All @@ -1515,7 +1515,7 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t
cmd = &exec.Cmd{Path: commandPath, Dir: repoDirectory, Env: os.Environ(), Args: []string{"git", "commit", "-m", "\"commit\""}, Stdout: out, Stderr: out}
err = cmd.Run()
if err != nil {
fmt.Printf("command '%v' resulted in an error and its output is:\n", cmd.String())
fmt.Printf("output from '%v' is:\n", cmd.String())
fmt.Printf("%v\n", out.String())
}
assert.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,10 @@ public void isCleanWithTextFileContainingLineFeedsUsingGitCommandTest()
File repoDirectory = new File(testDirectory, "testrepo");
Process p = new ProcessBuilder(new String[]{"git", "init", "testrepo"}).directory(testDirectory).redirectErrorStream(true).start();
p.waitFor();
System.out.println("Output from 'git init testrepo' is:");
System.out.write(p.getInputStream().readAllBytes());
System.out.println();
System.out.flush();
p.destroy();

assertTrue(JGitRepository.open(repoDirectory).isClean());
Expand All @@ -1393,12 +1397,20 @@ public void isCleanWithTextFileContainingLineFeedsUsingGitCommandTest()
// stage the files without committing
p = new ProcessBuilder(new String[]{"git", "add", "."}).directory(repoDirectory).redirectErrorStream(true).start();
p.waitFor();
System.out.println("Output from 'git add .' is:");
System.out.write(p.getInputStream().readAllBytes());
System.out.println();
System.out.flush();
p.destroy();
assertFalse(JGitRepository.open(repoDirectory).isClean());

// commit the files, now we're supposed to be clean again but when the bug is present we're not
p = new ProcessBuilder(new String[]{"git", "commit", "-m", "\"commit\""}).directory(repoDirectory).redirectErrorStream(true).start();
p.waitFor();
System.out.println("Output from 'git commit -m \"commit\"' is:");
System.out.write(p.getInputStream().readAllBytes());
System.out.println();
System.out.flush();
p.destroy();
// when the bug is present, this call to IsClean() returns false even if it's supposed to return true
assertTrue(JGitRepository.open(repoDirectory).isClean());
Expand Down

0 comments on commit 8477ff3

Please sign in to comment.