creation on DEB packages

with improved version numbering
This commit is contained in:
Johan Holmberg 2016-10-07 16:45:10 +02:00
parent e9974f5922
commit 3f80a9a1ea
3 changed files with 142 additions and 3 deletions

84
CMakeLists.txt Normal file
View File

@ -0,0 +1,84 @@
cmake_minimum_required(VERSION 3.0)
project(cmdtest)
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ruby bin/cmdtest.rb --shortversion
OUTPUT_VARIABLE CMDTEST_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND date +%Y%m%d
OUTPUT_VARIABLE CMDTEST_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CPACK_GENERATOR "DEB;STGZ;TGZ;TZ")
set(CPACK_PACKAGE_VERSION "${CMDTEST_VERSION}.${CMDTEST_DATE}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Johan Holmberg <holmberg556@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Cmdtest, xUnit style testing of commands")
set(CPACK_PACKAGE_DESCRIPTION "Cmdtest, xUnit style testing of commands ...")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "ruby | ruby-interpreter")
INCLUDE(CPack)
execute_process(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_REV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git show -s --format=%ci HEAD
OUTPUT_VARIABLE GIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "GIT_REV = '${GIT_REV}'")
message(STATUS "GIT_DATE = '${GIT_DATE}'")
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ./replace_strings.pl "GIT_REV_STRING=${GIT_REV}" "GIT_DATE_STRING=${GIT_DATE}" bin/cmdtest.rb bin/cmdtest.rb.generated
)
install(
FILES
lib/cmdtest/argumentparser.rb
lib/cmdtest/baselogger.rb
lib/cmdtest/cmdeffects.rb
lib/cmdtest/consolelogger.rb
lib/cmdtest/fileinfo.rb
lib/cmdtest/fssnapshot.rb
lib/cmdtest/junitfile.rb
lib/cmdtest/junitlogger.rb
lib/cmdtest/lcs.rb
lib/cmdtest/methodfilter.rb
lib/cmdtest/notify.rb
lib/cmdtest/output.rb
lib/cmdtest/testcase.rb
lib/cmdtest/util.rb
lib/cmdtest/workdir.rb
DESTINATION lib/ruby/vendor_ruby/cmdtest
)
install(
FILES
doc/cmdtest.html
COPYING.txt
README.html
DESTINATION share/doc/rake
)
install(
PROGRAMS
bin/cmdtest.rb.generated
DESTINATION bin
RENAME cmdtest
)

View File

@ -25,9 +25,9 @@
# found in the files. The result can be reported in different ways.
# Most of the testing logic is found in the library files "cmdtest/*.rb".
top_dir = File.dirname(File.dirname(__FILE__))
lib_dir = File.join(File.expand_path(top_dir), "lib")
$:.unshift(lib_dir) if File.directory?(File.join(lib_dir, "cmdtest"))
TOP_DIR = File.expand_path(File.dirname(File.dirname(__FILE__)))
LIB_DIR = File.join(TOP_DIR, "lib")
$:.unshift(LIB_DIR) if File.directory?(File.join(LIB_DIR, "cmdtest"))
require "cmdtest/argumentparser"
require "cmdtest/baselogger"
@ -49,6 +49,11 @@ module Cmdtest
ORIG_CWD = Dir.pwd
GIT_REV = 'GIT_REV_STRING'
GIT_DATE = 'GIT_DATE_STRING'
VERSION = '1.4'
#----------------------------------------------------------------------
module LogBaseMixin
@ -573,6 +578,7 @@ module Cmdtest
def _parse_options
pr = @argument_parser = ArgumentParser.new("cmdtest")
pr.add("-h", "--help", "show this help message and exit")
pr.add("", "--shortversion", "show just version number")
pr.add("", "--version", "show version")
pr.add("-q", "--quiet", "be more quiet")
pr.add("-v", "--verbose", "be more verbose")
@ -598,6 +604,25 @@ module Cmdtest
def run
opts = _parse_options
if opts.shortversion
puts VERSION
exit(0)
elsif opts.version
puts "Version: " + VERSION
if File.directory?(File.join(TOP_DIR, ".git"))
Dir.chdir(TOP_DIR) do
git_rev = `git rev-parse HEAD`
git_date = `git show -s --format=%ci HEAD`
puts "Revision: #{git_rev}"
puts "Date: #{git_date}"
end
else
puts "Revision: #{GIT_REV}"
puts "Date: #{GIT_DATE}"
end
exit(0)
end
if opts.stop_on_error && opts.parallel != 1
puts "cmdtest: error: --stop-on-error can not be used with --parallel"
exit(1)

30
replace_strings.pl Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env perl
use strict;
my @replace;
while (@ARGV > 0 && $ARGV[0] =~ /^(\w+)=(.*)/) {
my ($old, $new) = ($1, $2);
push @replace, [$old, $new];
shift @ARGV;
}
if (@ARGV != 2) {
die "Usage: replace_strings K1=V1 ... Kn=Vn INFILE OUTFILE\n";
}
my ($infile, $outfile) = @ARGV;
open(my $f, '<', $infile) || die "open($infile)";
open(my $g, '>', $outfile) || die "open($outfile)";
while (my $line = <$f>) {
for my $entry (@replace) {
my ($old, $new) = @$entry;
$line =~ s/$old/$new/g;
}
print {$g} $line;
}
close($f) || die "close($infile)";
close($g) || die "close($outfile)";