Skip to content

Commit 00cb407

Browse files
committed
Added tests for Ada, bumped the version number.
1 parent 0832f19 commit 00cb407

File tree

8 files changed

+93
-5
lines changed

8 files changed

+93
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15.5)
22
project(duplo)
33
file(GLOB SOURCES src/*.cpp)
44

5-
SET(DUPLO_VERSION "\"v1.0.0\"" CACHE STRING "Duplo version")
5+
SET(DUPLO_VERSION "\"v1.0.1\"" CACHE STRING "Duplo version")
66

77
if(MSVC)
88
else()

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM alpine:3.11 AS build
2-
ARG DUPLO_VERSION=v1.0.0
2+
ARG DUPLO_VERSION=v1.0.1
33

44
RUN apk --no-cache add \
55
alpine-sdk cmake

compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# to run this, first set the DUPLO_VERSION environment variable. Otherwise
33
# some of the tests might fail. So, do this:
4-
# > export DUPLO_VERSION=v1.0.0
4+
# > export DUPLO_VERSION=v1.0.1
55
p() {
66
now="$(date +'%r')"
77
printf "$(tput setaf 1)%s$(tput sgr0) | $(tput bold)$1$(tput sgr0)\n" "$now";

src/Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace {
5151

5252
std::cout << "\nDESCRIPTION\n";
5353
std::cout << " Duplo is a tool to find duplicated code blocks in large\n";
54-
std::cout << " C/C++/Java/C#/VB.Net software systems.\n\n";
54+
std::cout << " C/C++/Java/C#/VB.Net/Ada software systems.\n\n";
5555

5656
std::cout << " -ml minimal block size in lines (default is " << MIN_BLOCK_SIZE << ")\n";
5757
std::cout << " -pt percentage of lines of duplication threshold to override -ml\n";

tests/Simple_Ada/simple_log.adb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
with Ada.Text_IO;
2+
3+
package body Simple_Log is
4+
5+
use Ada.Text_IO;
6+
7+
--
8+
Current_Output_Level : Output_Level_Type := Info;
9+
10+
--
11+
procedure Set_Output (New_Output_Level : in Output_Level_Type) is
12+
begin
13+
Current_Output_Level := New_Output_Level;
14+
end Set_Output;
15+
16+
--
17+
procedure Error (Message : in String) is
18+
begin
19+
if Current_Output_Level >= Error then
20+
Put_Line (Standard_Error, Message); -- For errors
21+
-- Comments should be ignored, also as lines in between
22+
end if;
23+
end Error;
24+
25+
--
26+
procedure Warning (Message : in String) is
27+
begin
28+
if Current_Output_Level >= Warning then
29+
Put_Line (Standard_Error, Message); -- For warnings
30+
end if;
31+
end Warning;
32+
33+
--
34+
procedure Info (Message : in String) is
35+
begin
36+
if Current_Output_Level >= Info then
37+
Put_Line (Standard_Error, Message); -- For info
38+
end if;
39+
end Info;
40+
41+
--
42+
procedure Debug (Message : in String) is
43+
begin
44+
if Current_Output_Level >= Debug then
45+
Put_Line (Standard_Error, Message); -- For debug
46+
end if;
47+
end Debug;
48+
49+
end Simple_Log;

tests/Simple_Ada/simple_log.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/Simple_Ada/simple_log.adb

tests/Simple_Ada/tests.bats

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
setup() {
2+
run ./build/duplo -ml 2 tests/Simple_Ada/simple_log.lst out.txt
3+
}
4+
5+
@test "simple_log.adb" {
6+
[ "$status" -eq 0 ]
7+
[ "${lines[0]}" = "Loading and hashing files ... 2 done." ]
8+
[ "${lines[1]}" = "tests/Simple_Ada/simple_log.adb found: 6 block(s)" ]
9+
}
10+
11+
@test "simple_log.adb out.txt" {
12+
run cat out.txt
13+
printf 'Lines:\n'
14+
printf 'lines %s\n' "${lines[@]}" >&2
15+
printf 'output %s\n' "${output[@]}" >&2
16+
[ "${lines[0]}" = "tests/Simple_Ada/simple_log.adb(29)" ]
17+
[ "${lines[1]}" = "tests/Simple_Ada/simple_log.adb(20)" ]
18+
[ "${lines[4]}" = "tests/Simple_Ada/simple_log.adb(37)" ]
19+
[ "${lines[5]}" = "tests/Simple_Ada/simple_log.adb(29)" ]
20+
[ "${lines[8]}" = "tests/Simple_Ada/simple_log.adb(45)" ]
21+
[ "${lines[9]}" = "tests/Simple_Ada/simple_log.adb(37)" ]
22+
[ "${lines[12]}" = "tests/Simple_Ada/simple_log.adb(37)" ]
23+
[ "${lines[13]}" = "tests/Simple_Ada/simple_log.adb(20)" ]
24+
[ "${lines[16]}" = "tests/Simple_Ada/simple_log.adb(45)" ]
25+
[ "${lines[17]}" = "tests/Simple_Ada/simple_log.adb(29)" ]
26+
[ "${lines[20]}" = "tests/Simple_Ada/simple_log.adb(45)" ]
27+
[ "${lines[21]}" = "tests/Simple_Ada/simple_log.adb(20)" ]
28+
[ "${lines[24]}" = "Configuration:" ]
29+
[ "${lines[25]}" = " Number of files: 1" ]
30+
[ "${lines[26]}" = " Minimal block size: 2" ]
31+
[ "${lines[27]}" = " Minimal characters in line: 3" ]
32+
[ "${lines[28]}" = " Ignore preprocessor directives: 0" ]
33+
[ "${lines[29]}" = " Ignore same filenames: 0" ]
34+
[ "${lines[30]}" = "Results:" ]
35+
[ "${lines[31]}" = " Lines of code: 33" ]
36+
[ "${lines[32]}" = " Duplicate lines of code: 12" ]
37+
[ "${lines[33]}" = " Total 6 duplicate block(s) found." ]
38+
}

tests/test.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[ "${lines[3]}" = " duplo [OPTIONS] [INTPUT_FILELIST] [OUTPUT_FILE]" ]
1010
[ "${lines[4]}" = "DESCRIPTION" ]
1111
[ "${lines[5]}" = " Duplo is a tool to find duplicated code blocks in large" ]
12-
[ "${lines[6]}" = " C/C++/Java/C#/VB.Net software systems." ]
12+
[ "${lines[6]}" = " C/C++/Java/C#/VB.Net/Ada software systems." ]
1313
[ "${lines[7]}" = " -ml minimal block size in lines (default is 4)" ]
1414
[ "${lines[8]}" = " -pt percentage of lines of duplication threshold to override -ml" ]
1515
[ "${lines[9]}" = " (default is 100%)" ]

0 commit comments

Comments
 (0)