Skip to content

Commit 00aabc5

Browse files
committed
Merge branch 'return-code'
2 parents f766cef + d441a92 commit 00aabc5

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

src/Duplo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ namespace {
356356
}
357357
}
358358

359-
void Duplo::Run(const Options& options) {
359+
int Duplo::Run(const Options& options) {
360360
std::streambuf* buf;
361361
std::streambuf* logbuf;
362362
std::ofstream of;
@@ -507,4 +507,8 @@ void Duplo::Run(const Options& options) {
507507
<< std::endl
508508
<< std::endl;
509509
}
510+
511+
return processResultTotal.Blocks() > 0
512+
? EXIT_FAILURE
513+
: EXIT_SUCCESS;
510514
}

src/Main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ namespace {
4242
ignoreSameFilename,
4343
listFilename,
4444
outputFilename);
45-
Duplo::Run(options);
46-
return EXIT_SUCCESS;
45+
return Duplo::Run(options);
4746
} else {
4847
std::cout << "\nNAME\n";
4948
std::cout << " Duplo " << VERSION << " - duplicate source code block finder\n\n";

src/include/Duplo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const std::string VERSION = "";
1414
#endif
1515

1616
namespace Duplo {
17-
void Run(const Options& options);
17+
int Run(const Options& options);
1818
}
1919

2020
#endif

tests/Simple/test-xml.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@test "LineNumbers.c" {
44
run ./build/duplo -xml tests/Simple/LineNumbers.lst out.xml
5-
[ "$status" -eq 0 ]
5+
[ "$status" -eq 1 ]
66
[ "${lines[0]}" = "Loading and hashing files ... 2 done." ]
77
}
88

tests/Simple/tests.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@test "LineNumbers.c" {
44
run ./build/duplo tests/Simple/LineNumbers.lst out.txt
5-
[ "$status" -eq 0 ]
5+
[ "$status" -eq 1 ]
66
[ "${lines[0]}" = "Loading and hashing files ... 2 done." ]
77
[ "${lines[1]}" = "tests/Simple/LineNumbers.c found: 1 block(s)" ]
88
}

tests/Simple_Ada/tests.bats

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
@test "simple_log.adb" {
44
run ./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst out.txt
5-
[ "$status" -eq 0 ]
5+
[ "$status" -eq 1 ]
66
[ "${lines[0]}" = "Loading and hashing files ... 2 done." ]
77
[ "${lines[1]}" = "tests/Simple_Ada/simple_log.adb found: 6 block(s)" ]
88
}
99

1010
@test "simple_log.adb out.txt" {
11-
./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst -
11+
run ./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst -
12+
[ "$status" -eq 1 ]
1213
run diff <(cat tests/Simple_Ada/expected.log) <(./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst -)
1314
[ "$status" -eq 0 ]
1415
printf 'Lines:\n'

0 commit comments

Comments
 (0)