Code review feedback, normalize whitespace to spaces

This commit is contained in:
Bryan 2015-10-16 12:13:52 -07:00
parent c38ccd8054
commit 7b8b4b10e0
8 changed files with 438 additions and 439 deletions

1
.gitignore vendored
View file

@ -1,6 +1,5 @@
[Oo]bj/
# Top level bin ignore only, so package_tool test_assets are added correctly
/[Bb]in/
.nuget/
_ReSharper.*/
packages/

View file

@ -1,39 +1,39 @@
{
"maintainer_name":"Microsoft", // [required]
"maintainer_email": "optimus@service.microsoft.com", // [required]
"maintainer_name":"Microsoft",
"maintainer_email": "optimus@service.microsoft.com",
"package_name": "Packagify_Test", // [required]
"package_name": "Packagify_Test",
"short_description": "This is a test package", // [required] Max. 60 chars
"long_description": "This is a longer description of the test package", // [required]
"homepage": "http://testpackage.com", // (optional no default)
"short_description": "This is a test package",
"long_description": "This is a longer description of the test package",
"homepage": "http://testpackage.com",
"release":{
"package_version":"0.1", // [required]
"package_revision":"1", // [required]
"urgency" : "low", // (optional default="low") https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Urgency
"changelog_message" : "some stuff here" // [required]
"package_version":"0.1",
"package_revision":"1",
"urgency" : "low",
"changelog_message" : "some stuff here"
},
"control": { // (optional)
"priority":"standard", // (optional default="standard") https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
"section":"devel", // (optional default="misc") https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
"architecture":"all" // (optional default="all" )
"control": {
"priority":"standard",
"section":"devel",
"architecture":"all"
},
"copyright": "2015 Microsoft", // [required]
"license": { // [required]
"type": "some_license", // [required]
"full_text": "full license text here" // [required]
"copyright": "2015 Microsoft",
"license": {
"type": "some_license",
"full_text": "full license text here"
},
"debian_dependencies" : { // (optional no default)
"debian_dependencies" : {
"package_name": {
"package_version" : "1.0.0" // (optional within package_name no default)
"package_version" : "1.0.0"
}
},
},
"symlinks": { // (optional no defaults)
"path_relative_to_package_root/test_exe.sh" : "usr/bin/test_exe.sh"
"symlinks": {
"path_relative_to_package_root/test_exe.sh" : "usr/bin/test_exe.sh"
}
}

View file

@ -3,35 +3,35 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
current_user=$(whoami)
if [ $current_user != "root" ]; then
echo "test.sh requires superuser privileges to run"
exit 1
echo "test.sh requires superuser privileges to run"
exit 1
fi
run_unit_tests(){
bats $DIR/test/unit_tests/test_debian_build_lib.bats
bats $DIR/test/unit_tests/test_scripts.bats
bats $DIR/test/unit_tests/test_debian_build_lib.bats
bats $DIR/test/unit_tests/test_scripts.bats
}
run_integration_tests(){
input_dir=$DIR/test/test_assets/test_package_layout
output_dir=$DIR/p_out
input_dir=$DIR/test/test_assets/test_package_layout
output_dir=$DIR/p_out
# Create output dir
mkdir -p $output_dir
# Create output dir
mkdir -p $output_dir
# Build the actual package
$DIR/package_tool $input_dir $output_dir
# Build the actual package
$DIR/package_tool $input_dir $output_dir
# Integration Test Entrypoint placed by package_tool
bats $output_dir/test_package.bats
# Integration Test Entrypoint placed by package_tool
bats $output_dir/test_package.bats
# Cleanup output dir
rm -rf $DIR/test/test_assets/test_package_output
# Cleanup output dir
rm -rf $DIR/test/test_assets/test_package_output
}
run_all(){
run_unit_tests
run_integration_tests
run_unit_tests
run_integration_tests
}
run_all

View file

@ -1,108 +1,108 @@
{
"tools": {
"tool1": {
"copyright": "This is the copyright of tool1.",
"license" : "This is the license of tool1",
"author":"Test Author",
"author_email":"testing@testing.com",
"short_description":"A tool to Vestibulum lacinia arcu eget nulla.",
"long_description":"Tool1 is a really great Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. ",
"commands": {
"fullcommand1":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
},
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noOptionsCommand":{
"description":"builds a native executable from specified source files",
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noArgumentListFullOptions":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
}
}
}
}
}
"tools": {
"tool1": {
"copyright": "This is the copyright of tool1.",
"license" : "This is the license of tool1",
"author":"Test Author",
"author_email":"testing@testing.com",
"short_description":"A tool to Vestibulum lacinia arcu eget nulla.",
"long_description":"Tool1 is a really great Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. ",
"commands": {
"fullcommand1":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
},
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noOptionsCommand":{
"description":"builds a native executable from specified source files",
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noArgumentListFullOptions":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
}
}
}
}
}
}

View file

@ -2,8 +2,8 @@ using System;
public class Program {
public static void Main(){
System.Console.WriteLine("Hello World");
}
public static void Main(){
System.Console.WriteLine("Hello World");
}
}

View file

@ -1,108 +1,108 @@
{
"tools": {
"tool1": {
"copyright": "This is the copyright of tool1.",
"license" : "This is the license of tool1",
"author":"Test Author",
"author_email":"testing@testing.com",
"short_description":"A tool to Vestibulum lacinia arcu eget nulla.",
"long_description":"Tool1 is a really great Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. ",
"commands": {
"fullcommand1":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
},
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noOptionsCommand":{
"description":"builds a native executable from specified source files",
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noArgumentListFullOptions":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
}
}
}
}
}
"tools": {
"tool1": {
"copyright": "This is the copyright of tool1.",
"license" : "This is the license of tool1",
"author":"Test Author",
"author_email":"testing@testing.com",
"short_description":"A tool to Vestibulum lacinia arcu eget nulla.",
"long_description":"Tool1 is a really great Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. ",
"commands": {
"fullcommand1":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
},
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noOptionsCommand":{
"description":"builds a native executable from specified source files",
"argumentlist" : {
"name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
}
},
"noArgumentListFullOptions":{
"description":"builds a native executable from specified source files",
"options" : {
"target": {
"short": "-t",
"long":"--target",
"description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET"
},
"target2": {
"short": "-a",
"long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER"
},
"noshort": {
"long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT"
},
"nolong": {
"short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG"
},
"noparam": {
"short": "-p",
"long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem"
},
"noParamNoShort": {
"long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
},
"noParamNoLong": {
"short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
}
}
}
}
}
}
}

View file

@ -3,273 +3,273 @@
# Tests for debian_build_lib.sh
setup(){
DIR="$BATS_TEST_DIRNAME"
PACKAGIFY_DIR="$(readlink -f $DIR/../../)"
DIR="$BATS_TEST_DIRNAME"
PACKAGIFY_DIR="$(readlink -f $DIR/../../)"
PACKAGE_DIR="$BATS_TMPDIR/test-package"
PACKAGE_SOURCE_DIR="$BATS_TMPDIR/test-source-package"
INSTALL_ROOT="test-install-root"
PACKAGE_DIR="$BATS_TMPDIR/test-package"
PACKAGE_SOURCE_DIR="$BATS_TMPDIR/test-source-package"
INSTALL_ROOT="test-install-root"
# # Create Mock Package Directory
mkdir -p $PACKAGE_SOURCE_DIR/debian
mkdir $PACKAGE_DIR
# # Create Mock Package Directory
mkdir -p $PACKAGE_SOURCE_DIR/debian
mkdir $PACKAGE_DIR
source $PACKAGIFY_DIR/scripts/debian_build_lib.sh
source $PACKAGIFY_DIR/scripts/debian_build_lib.sh
}
teardown(){
# Remove Mock Package Directory
rm -r $PACKAGE_DIR
rm -r $PACKAGE_SOURCE_DIR
# Remove Mock Package Directory
rm -r $PACKAGE_DIR
rm -r $PACKAGE_SOURCE_DIR
}
@test "add_system_file_placement populates placement array" {
add_system_file_placement "testfile0" "testdir0"
add_system_file_placement "testfile1" "testdir1"
add_system_file_placement "testfile0" "testdir0"
add_system_file_placement "testfile1" "testdir1"
[ $placement_index -eq "2" ]
[ "${install_placement[0]}" = "testfile0 testdir0" ]
[ "${install_placement[1]}" = "testfile1 testdir1" ]
[ $placement_index -eq "2" ]
[ "${install_placement[0]}" = "testfile0 testdir0" ]
[ "${install_placement[1]}" = "testfile1 testdir1" ]
}
@test "add_system_dir_placement adds files in dir to placement array" {
test_package_rel_dir="test-dir"
abs_test_path="/abs/test/path"
test_package_rel_dir="test-dir"
abs_test_path="/abs/test/path"
mkdir $PACKAGE_SOURCE_DIR/$test_package_rel_dir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file2
mkdir $PACKAGE_SOURCE_DIR/$test_package_rel_dir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file2
add_system_dir_placement $test_package_rel_dir $abs_test_path
add_system_dir_placement $test_package_rel_dir $abs_test_path
rm -r $PACKAGE_SOURCE_DIR/$test_package_rel_dir
rm -r $PACKAGE_SOURCE_DIR/$test_package_rel_dir
[ "$placement_index" -eq 3 ]
[ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/file1 $abs_test_path" ]
[ "${install_placement[2]}" = "$test_package_rel_dir/file2 $abs_test_path" ]
[ "$placement_index" -eq 3 ]
[ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/file1 $abs_test_path" ]
[ "${install_placement[2]}" = "$test_package_rel_dir/file2 $abs_test_path" ]
}
@test "add_system_dir_placement adds all files in subdir to placement array" {
test_package_rel_dir="test-dir"
test_package_rel_subdir="test-subdir"
abs_test_path="/abs/test/path"
test_package_rel_dir="test-dir"
test_package_rel_subdir="test-subdir"
abs_test_path="/abs/test/path"
mkdir -p $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file2
mkdir -p $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file2
add_system_dir_placement $test_package_rel_dir $abs_test_path
add_system_dir_placement $test_package_rel_dir $abs_test_path
rm -r $PACKAGE_SOURCE_DIR/$test_package_rel_dir
rm -r $PACKAGE_SOURCE_DIR/$test_package_rel_dir
[ "$placement_index" -eq "3" ]
[ "${install_placement[0]}" = "$test_package_rel_dir/$test_package_rel_subdir/file0 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/$test_package_rel_subdir/file1 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[2]}" = "$test_package_rel_dir/$test_package_rel_subdir/file2 $abs_test_path/$test_package_rel_subdir" ]
[ "$placement_index" -eq "3" ]
[ "${install_placement[0]}" = "$test_package_rel_dir/$test_package_rel_subdir/file0 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/$test_package_rel_subdir/file1 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[2]}" = "$test_package_rel_dir/$test_package_rel_subdir/file2 $abs_test_path/$test_package_rel_subdir" ]
}
@test "add_system_dir_placement adds all files in subdir and dir to placement array" {
test_package_rel_dir="test-dir"
test_package_rel_subdir="test-subdir"
abs_test_path="/abs/test/path"
test_package_rel_dir="test-dir"
test_package_rel_subdir="test-subdir"
abs_test_path="/abs/test/path"
mkdir -p $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file2
echo "file3 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file3
echo "file4 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file4
echo "file5 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file5
mkdir -p $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file2
echo "file3 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file3
echo "file4 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file4
echo "file5 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir/file5
add_system_dir_placement $test_package_rel_dir $abs_test_path
add_system_dir_placement $test_package_rel_dir $abs_test_path
rm -r $PACKAGE_SOURCE_DIR/$test_package_rel_dir
rm -r $PACKAGE_SOURCE_DIR/$test_package_rel_dir
[ "$placement_index" -eq "6" ]
[ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/file1 $abs_test_path" ]
[ "${install_placement[2]}" = "$test_package_rel_dir/file2 $abs_test_path" ]
[ "${install_placement[3]}" = "$test_package_rel_dir/$test_package_rel_subdir/file3 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[4]}" = "$test_package_rel_dir/$test_package_rel_subdir/file4 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[5]}" = "$test_package_rel_dir/$test_package_rel_subdir/file5 $abs_test_path/$test_package_rel_subdir" ]
[ "$placement_index" -eq "6" ]
[ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/file1 $abs_test_path" ]
[ "${install_placement[2]}" = "$test_package_rel_dir/file2 $abs_test_path" ]
[ "${install_placement[3]}" = "$test_package_rel_dir/$test_package_rel_subdir/file3 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[4]}" = "$test_package_rel_dir/$test_package_rel_subdir/file4 $abs_test_path/$test_package_rel_subdir" ]
[ "${install_placement[5]}" = "$test_package_rel_dir/$test_package_rel_subdir/file5 $abs_test_path/$test_package_rel_subdir" ]
}
@test "write_debian_install_file writes to debian/install" {
add_system_file_placement "somefile" "/some/abs/path"
write_debian_install_file
add_system_file_placement "somefile" "/some/abs/path"
write_debian_install_file
[ -f "$PACKAGE_SOURCE_DIR/debian/install" ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "somefile /some/abs/path" ]
[ -f "$PACKAGE_SOURCE_DIR/debian/install" ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "somefile /some/abs/path" ]
}
@test "add_file_to_install adds file to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir"
local_subdir="the/path/should/not/matter"
package_test_dir="package-dir"
local_test_dir="$BATS_TMPDIR/local-dir"
local_subdir="the/path/should/not/matter"
package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_subdir
echo "file0 contents" > $local_test_dir/$local_subdir/file0
echo "file1 contents" > $local_test_dir/$local_subdir/file1
echo "file2 contents" > $local_test_dir/$local_subdir/file2
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_subdir
echo "file0 contents" > $local_test_dir/$local_subdir/file0
echo "file1 contents" > $local_test_dir/$local_subdir/file1
echo "file2 contents" > $local_test_dir/$local_subdir/file2
add_file_to_install "$local_test_dir/$local_subdir/file0" "$package_test_dir"
add_file_to_install "$local_test_dir/$local_subdir/file1" "$package_test_dir"
add_file_to_install "$local_test_dir/$local_subdir/file2" "$package_test_dir"
add_file_to_install "$local_test_dir/$local_subdir/file0" "$package_test_dir"
add_file_to_install "$local_test_dir/$local_subdir/file1" "$package_test_dir"
add_file_to_install "$local_test_dir/$local_subdir/file2" "$package_test_dir"
rm -r $local_test_dir
rm -r $local_test_dir
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
}
@test "add_file_to_install added files written to install file after write_debian_install_file" {
local_test_dir="$BATS_TMPDIR/local-dir"
local_subdir="the/path/should/not/matter"
package_test_dir="package-dir"
local_test_dir="$BATS_TMPDIR/local-dir"
local_subdir="the/path/should/not/matter"
package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_subdir
echo "file0 contents" > $local_test_dir/$local_subdir/file0
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_subdir
echo "file0 contents" > $local_test_dir/$local_subdir/file0
add_file_to_install "$local_test_dir/$local_subdir/file0" "$package_test_dir"
add_file_to_install "$local_test_dir/$local_subdir/file0" "$package_test_dir"
rm -r $local_test_dir
rm -r $local_test_dir
[ ! -e $PACKAGE_SOURCE_DIR/debian/install ]
write_debian_install_file
[ -f $PACKAGE_SOURCE_DIR/debian/install ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "$package_test_dir/file0 $INSTALL_ROOT/$package_test_dir" ]
[ ! -e $PACKAGE_SOURCE_DIR/debian/install ]
write_debian_install_file
[ -f $PACKAGE_SOURCE_DIR/debian/install ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "$package_test_dir/file0 $INSTALL_ROOT/$package_test_dir" ]
}
@test "add_dir_to_install adds files in dir to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir"
package_test_dir="package-dir"
local_test_dir="$BATS_TMPDIR/local-dir"
package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir $local_test_dir
echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir $local_test_dir
echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2
add_dir_to_install "$local_test_dir" "$package_test_dir"
add_dir_to_install "$local_test_dir" "$package_test_dir"
rm -r $local_test_dir
rm -r $local_test_dir
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
}
@test "add_dir_to_install adds files in subdirectory tree to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir"
local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir"
package_test_dir="package-dir"
package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_test_subdir
echo "file0 contents" > $local_test_dir/$local_test_subdir/file0
echo "file1 contents" > $local_test_dir/$local_test_subdir/file1
echo "file2 contents" > $local_test_dir/$local_test_subdir/file2
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_test_subdir
echo "file0 contents" > $local_test_dir/$local_test_subdir/file0
echo "file1 contents" > $local_test_dir/$local_test_subdir/file1
echo "file2 contents" > $local_test_dir/$local_test_subdir/file2
add_dir_to_install "$local_test_dir" "$package_test_dir"
add_dir_to_install "$local_test_dir" "$package_test_dir"
rm -r $local_test_dir
rm -r $local_test_dir
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file2" ]
}
@test "add_dir_to_install adds files in directory and subdirectory tree to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir"
local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir"
package_test_dir="package-dir"
package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_test_subdir
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_test_subdir
echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2
echo "file3 contents" > $local_test_dir/$local_test_subdir/file3
echo "file4 contents" > $local_test_dir/$local_test_subdir/file4
echo "file5 contents" > $local_test_dir/$local_test_subdir/file5
echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2
echo "file3 contents" > $local_test_dir/$local_test_subdir/file3
echo "file4 contents" > $local_test_dir/$local_test_subdir/file4
echo "file5 contents" > $local_test_dir/$local_test_subdir/file5
add_dir_to_install "$local_test_dir" "$package_test_dir"
add_dir_to_install "$local_test_dir" "$package_test_dir"
rm -r $local_test_dir
rm -r $local_test_dir
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file3" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file4" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file5" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file3" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file4" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file5" ]
}
@test "add_dir_to_install added files written to install file after write_debian_install_file" {
local_test_dir="$BATS_TMPDIR/local-dir"
package_test_dir="package-dir"
local_test_dir="$BATS_TMPDIR/local-dir"
package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir
echo "file0 contents" > $local_test_dir/file0
echo "file0 contents" > $local_test_dir/file0
add_dir_to_install "$local_test_dir" "$package_test_dir"
add_dir_to_install "$local_test_dir" "$package_test_dir"
rm -r $local_test_dir
rm -r $local_test_dir
[ ! -e $PACKAGE_SOURCE_DIR/debian/install ]
write_debian_install_file
[ -f $PACKAGE_SOURCE_DIR/debian/install ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "$package_test_dir/file0 $INSTALL_ROOT/$package_test_dir" ]
[ ! -e $PACKAGE_SOURCE_DIR/debian/install ]
write_debian_install_file
[ -f $PACKAGE_SOURCE_DIR/debian/install ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "$package_test_dir/file0 $INSTALL_ROOT/$package_test_dir" ]
}
@test "add_dir_to_install with empty dest dir outputs to PACKAGE_SOURCE_DIR" {
local_test_dir="$BATS_TMPDIR/local-dir"
mkdir -p $local_test_dir
local_test_dir="$BATS_TMPDIR/local-dir"
mkdir -p $local_test_dir
echo "file0 contents" > $local_test_dir/file0
echo "file0 contents" > $local_test_dir/file0
add_dir_to_install "$local_test_dir" ""
add_dir_to_install "$local_test_dir" ""
rm -r $local_test_dir
rm -r $local_test_dir
[ -f "$PACKAGE_SOURCE_DIR/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/file0" ]
}
@test "add_dir_to_install with empty dest dir adds files in directory and subdirectory tree to $PACKAGE_SOURCE_DIR" {
local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir"
local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir"
mkdir -p $local_test_dir/$local_test_subdir
mkdir -p $local_test_dir/$local_test_subdir
echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2
echo "file3 contents" > $local_test_dir/$local_test_subdir/file3
echo "file4 contents" > $local_test_dir/$local_test_subdir/file4
echo "file5 contents" > $local_test_dir/$local_test_subdir/file5
echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2
echo "file3 contents" > $local_test_dir/$local_test_subdir/file3
echo "file4 contents" > $local_test_dir/$local_test_subdir/file4
echo "file5 contents" > $local_test_dir/$local_test_subdir/file5
add_dir_to_install "$local_test_dir" ""
add_dir_to_install "$local_test_dir" ""
rm -r $local_test_dir
rm -r $local_test_dir
[ -f "$PACKAGE_SOURCE_DIR/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file3" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file4" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file5" ]
[ -f "$PACKAGE_SOURCE_DIR/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file3" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file4" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file5" ]
}

View file

@ -3,22 +3,22 @@
# Tests for debian_build_lib.sh
setup(){
DIR="$BATS_TEST_DIRNAME"
PACKAGIFY_DIR="$(readlink -f $DIR/../../)"
DIR="$BATS_TEST_DIRNAME"
PACKAGIFY_DIR="$(readlink -f $DIR/../../)"
}
@test "manpage generation is identical to lkg file" {
# Output is file "tool1.1"
# LKG file is "lkgtestman.1"
python $PACKAGIFY_DIR/scripts/manpage_generator.py $PACKAGIFY_DIR/test/test_assets/testdocs.json $PACKAGIFY_DIR/test/test_assets
# Output is file "tool1.1"
# LKG file is "lkgtestman.1"
python $PACKAGIFY_DIR/scripts/manpage_generator.py $PACKAGIFY_DIR/test/test_assets/testdocs.json $PACKAGIFY_DIR/test/test_assets
# Test Output existence
[ -f $PACKAGIFY_DIR/test/test_assets/tool1.1 ]
# Test Output matches LKG
# If this is failing double check line ending style
[ -z "$(diff "$PACKAGIFY_DIR/test/test_assets/tool1.1" "$PACKAGIFY_DIR/test/test_assets/lkgtestman.1")" ]
# Test Output existence
[ -f $PACKAGIFY_DIR/test/test_assets/tool1.1 ]
# Test Output matches LKG
# If this is failing double check line ending style
[ -z "$(diff "$PACKAGIFY_DIR/test/test_assets/tool1.1" "$PACKAGIFY_DIR/test/test_assets/lkgtestman.1")" ]
# Cleanup
rm $PACKAGIFY_DIR/test/test_assets/tool1.1
# Cleanup
rm $PACKAGIFY_DIR/test/test_assets/tool1.1
}