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/ [Oo]bj/
# Top level bin ignore only, so package_tool test_assets are added correctly # Top level bin ignore only, so package_tool test_assets are added correctly
/[Bb]in/
.nuget/ .nuget/
_ReSharper.*/ _ReSharper.*/
packages/ packages/

View file

@ -1,39 +1,39 @@
{ {
"maintainer_name":"Microsoft", // [required] "maintainer_name":"Microsoft",
"maintainer_email": "optimus@service.microsoft.com", // [required] "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 "short_description": "This is a test package",
"long_description": "This is a longer description of the test package", // [required] "long_description": "This is a longer description of the test package",
"homepage": "http://testpackage.com", // (optional no default) "homepage": "http://testpackage.com",
"release":{ "release":{
"package_version":"0.1", // [required] "package_version":"0.1",
"package_revision":"1", // [required] "package_revision":"1",
"urgency" : "low", // (optional default="low") https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Urgency "urgency" : "low",
"changelog_message" : "some stuff here" // [required] "changelog_message" : "some stuff here"
}, },
"control": { // (optional) "control": {
"priority":"standard", // (optional default="standard") https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities "priority":"standard",
"section":"devel", // (optional default="misc") https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections "section":"devel",
"architecture":"all" // (optional default="all" ) "architecture":"all"
}, },
"copyright": "2015 Microsoft", // [required] "copyright": "2015 Microsoft",
"license": { // [required] "license": {
"type": "some_license", // [required] "type": "some_license",
"full_text": "full license text here" // [required] "full_text": "full license text here"
}, },
"debian_dependencies" : { // (optional no default) "debian_dependencies" : {
"package_name": { "package_name": {
"package_version" : "1.0.0" // (optional within package_name no default) "package_version" : "1.0.0"
} }
}, },
"symlinks": { // (optional no defaults) "symlinks": {
"path_relative_to_package_root/test_exe.sh" : "usr/bin/test_exe.sh" "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) current_user=$(whoami)
if [ $current_user != "root" ]; then if [ $current_user != "root" ]; then
echo "test.sh requires superuser privileges to run" echo "test.sh requires superuser privileges to run"
exit 1 exit 1
fi fi
run_unit_tests(){ run_unit_tests(){
bats $DIR/test/unit_tests/test_debian_build_lib.bats bats $DIR/test/unit_tests/test_debian_build_lib.bats
bats $DIR/test/unit_tests/test_scripts.bats bats $DIR/test/unit_tests/test_scripts.bats
} }
run_integration_tests(){ run_integration_tests(){
input_dir=$DIR/test/test_assets/test_package_layout input_dir=$DIR/test/test_assets/test_package_layout
output_dir=$DIR/p_out output_dir=$DIR/p_out
# Create output dir # Create output dir
mkdir -p $output_dir mkdir -p $output_dir
# Build the actual package # Build the actual package
$DIR/package_tool $input_dir $output_dir $DIR/package_tool $input_dir $output_dir
# Integration Test Entrypoint placed by package_tool # Integration Test Entrypoint placed by package_tool
bats $output_dir/test_package.bats bats $output_dir/test_package.bats
# Cleanup output dir # Cleanup output dir
rm -rf $DIR/test/test_assets/test_package_output rm -rf $DIR/test/test_assets/test_package_output
} }
run_all(){ run_all(){
run_unit_tests run_unit_tests
run_integration_tests run_integration_tests
} }
run_all run_all

View file

@ -1,108 +1,108 @@
{ {
"tools": { "tools": {
"tool1": { "tool1": {
"copyright": "This is the copyright of tool1.", "copyright": "This is the copyright of tool1.",
"license" : "This is the license of tool1", "license" : "This is the license of tool1",
"author":"Test Author", "author":"Test Author",
"author_email":"testing@testing.com", "author_email":"testing@testing.com",
"short_description":"A tool to Vestibulum lacinia arcu eget nulla.", "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. ", "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": { "commands": {
"fullcommand1":{ "fullcommand1":{
"description":"builds a native executable from specified source files", "description":"builds a native executable from specified source files",
"options" : { "options" : {
"target": { "target": {
"short": "-t", "short": "-t",
"long":"--target", "long":"--target",
"description":"Specifies target binary output type. EXE or DLL", "description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET" "parameter":"TARGET"
}, },
"target2": { "target2": {
"short": "-a", "short": "-a",
"long":"--another", "long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra", "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER" "parameter":"ANOTHER"
}, },
"noshort": { "noshort": {
"long":"--noshort", "long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt", "description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT" "parameter":"NOSHORT"
}, },
"nolong": { "nolong": {
"short": "-n", "short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ", "description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG" "parameter":"NOLONG"
}, },
"noparam": { "noparam": {
"short": "-p", "short": "-p",
"long":"--noparam", "long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem" "description":"Specifies noparam metus vitae pharetra auctor, sem"
}, },
"noParamNoShort": { "noParamNoShort": {
"long":"--noshortparam", "long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra" "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
}, },
"noParamNoLong": { "noParamNoLong": {
"short": "-l", "short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet" "description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
} }
}, },
"argumentlist" : { "argumentlist" : {
"name":"argument list stuff", "name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;" "description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
} }
}, },
"noOptionsCommand":{ "noOptionsCommand":{
"description":"builds a native executable from specified source files", "description":"builds a native executable from specified source files",
"argumentlist" : { "argumentlist" : {
"name":"argument list stuff", "name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;" "description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
} }
}, },
"noArgumentListFullOptions":{ "noArgumentListFullOptions":{
"description":"builds a native executable from specified source files", "description":"builds a native executable from specified source files",
"options" : { "options" : {
"target": { "target": {
"short": "-t", "short": "-t",
"long":"--target", "long":"--target",
"description":"Specifies target binary output type. EXE or DLL", "description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET" "parameter":"TARGET"
}, },
"target2": { "target2": {
"short": "-a", "short": "-a",
"long":"--another", "long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra", "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER" "parameter":"ANOTHER"
}, },
"noshort": { "noshort": {
"long":"--noshort", "long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt", "description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT" "parameter":"NOSHORT"
}, },
"nolong": { "nolong": {
"short": "-n", "short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ", "description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG" "parameter":"NOLONG"
}, },
"noparam": { "noparam": {
"short": "-p", "short": "-p",
"long":"--noparam", "long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem" "description":"Specifies noparam metus vitae pharetra auctor, sem"
}, },
"noParamNoShort": { "noParamNoShort": {
"long":"--noshortparam", "long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra" "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
}, },
"noParamNoLong": { "noParamNoLong": {
"short": "-l", "short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet" "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 class Program {
public static void Main(){ public static void Main(){
System.Console.WriteLine("Hello World"); System.Console.WriteLine("Hello World");
} }
} }

View file

@ -1,108 +1,108 @@
{ {
"tools": { "tools": {
"tool1": { "tool1": {
"copyright": "This is the copyright of tool1.", "copyright": "This is the copyright of tool1.",
"license" : "This is the license of tool1", "license" : "This is the license of tool1",
"author":"Test Author", "author":"Test Author",
"author_email":"testing@testing.com", "author_email":"testing@testing.com",
"short_description":"A tool to Vestibulum lacinia arcu eget nulla.", "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. ", "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": { "commands": {
"fullcommand1":{ "fullcommand1":{
"description":"builds a native executable from specified source files", "description":"builds a native executable from specified source files",
"options" : { "options" : {
"target": { "target": {
"short": "-t", "short": "-t",
"long":"--target", "long":"--target",
"description":"Specifies target binary output type. EXE or DLL", "description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET" "parameter":"TARGET"
}, },
"target2": { "target2": {
"short": "-a", "short": "-a",
"long":"--another", "long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra", "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER" "parameter":"ANOTHER"
}, },
"noshort": { "noshort": {
"long":"--noshort", "long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt", "description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT" "parameter":"NOSHORT"
}, },
"nolong": { "nolong": {
"short": "-n", "short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ", "description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG" "parameter":"NOLONG"
}, },
"noparam": { "noparam": {
"short": "-p", "short": "-p",
"long":"--noparam", "long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem" "description":"Specifies noparam metus vitae pharetra auctor, sem"
}, },
"noParamNoShort": { "noParamNoShort": {
"long":"--noshortparam", "long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra" "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
}, },
"noParamNoLong": { "noParamNoLong": {
"short": "-l", "short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet" "description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet"
} }
}, },
"argumentlist" : { "argumentlist" : {
"name":"argument list stuff", "name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;" "description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
} }
}, },
"noOptionsCommand":{ "noOptionsCommand":{
"description":"builds a native executable from specified source files", "description":"builds a native executable from specified source files",
"argumentlist" : { "argumentlist" : {
"name":"argument list stuff", "name":"argument list stuff",
"description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;" "description":"ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"
} }
}, },
"noArgumentListFullOptions":{ "noArgumentListFullOptions":{
"description":"builds a native executable from specified source files", "description":"builds a native executable from specified source files",
"options" : { "options" : {
"target": { "target": {
"short": "-t", "short": "-t",
"long":"--target", "long":"--target",
"description":"Specifies target binary output type. EXE or DLL", "description":"Specifies target binary output type. EXE or DLL",
"parameter":"TARGET" "parameter":"TARGET"
}, },
"target2": { "target2": {
"short": "-a", "short": "-a",
"long":"--another", "long":"--another",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra", "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra",
"parameter":"ANOTHER" "parameter":"ANOTHER"
}, },
"noshort": { "noshort": {
"long":"--noshort", "long":"--noshort",
"description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt", "description":"Specifies noshortNam nec ante. Sed lacinia, urna non tincidunt",
"parameter":"NOSHORT" "parameter":"NOSHORT"
}, },
"nolong": { "nolong": {
"short": "-n", "short": "-n",
"description":"Specifies nolong Nunc feugiat mi a tellus consequat ", "description":"Specifies nolong Nunc feugiat mi a tellus consequat ",
"parameter":"NOLONG" "parameter":"NOLONG"
}, },
"noparam": { "noparam": {
"short": "-p", "short": "-p",
"long":"--noparam", "long":"--noparam",
"description":"Specifies noparam metus vitae pharetra auctor, sem" "description":"Specifies noparam metus vitae pharetra auctor, sem"
}, },
"noParamNoShort": { "noParamNoShort": {
"long":"--noshortparam", "long":"--noshortparam",
"description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra" "description":"Specifies another aptent taciti sociosqu ad litora torquent per conubia nostra"
}, },
"noParamNoLong": { "noParamNoLong": {
"short": "-l", "short": "-l",
"description":"Specifies noparam nolong congue elementum. Morbi in ipsum sit amet pede facilisis laoreet" "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 # Tests for debian_build_lib.sh
setup(){ setup(){
DIR="$BATS_TEST_DIRNAME" DIR="$BATS_TEST_DIRNAME"
PACKAGIFY_DIR="$(readlink -f $DIR/../../)" PACKAGIFY_DIR="$(readlink -f $DIR/../../)"
PACKAGE_DIR="$BATS_TMPDIR/test-package" PACKAGE_DIR="$BATS_TMPDIR/test-package"
PACKAGE_SOURCE_DIR="$BATS_TMPDIR/test-source-package" PACKAGE_SOURCE_DIR="$BATS_TMPDIR/test-source-package"
INSTALL_ROOT="test-install-root" INSTALL_ROOT="test-install-root"
# # Create Mock Package Directory # # Create Mock Package Directory
mkdir -p $PACKAGE_SOURCE_DIR/debian mkdir -p $PACKAGE_SOURCE_DIR/debian
mkdir $PACKAGE_DIR mkdir $PACKAGE_DIR
source $PACKAGIFY_DIR/scripts/debian_build_lib.sh source $PACKAGIFY_DIR/scripts/debian_build_lib.sh
} }
teardown(){ teardown(){
# Remove Mock Package Directory # Remove Mock Package Directory
rm -r $PACKAGE_DIR rm -r $PACKAGE_DIR
rm -r $PACKAGE_SOURCE_DIR rm -r $PACKAGE_SOURCE_DIR
} }
@test "add_system_file_placement populates placement array" { @test "add_system_file_placement populates placement array" {
add_system_file_placement "testfile0" "testdir0" add_system_file_placement "testfile0" "testdir0"
add_system_file_placement "testfile1" "testdir1" add_system_file_placement "testfile1" "testdir1"
[ $placement_index -eq "2" ] [ $placement_index -eq "2" ]
[ "${install_placement[0]}" = "testfile0 testdir0" ] [ "${install_placement[0]}" = "testfile0 testdir0" ]
[ "${install_placement[1]}" = "testfile1 testdir1" ] [ "${install_placement[1]}" = "testfile1 testdir1" ]
} }
@test "add_system_dir_placement adds files in dir to placement array" { @test "add_system_dir_placement adds files in dir to placement array" {
test_package_rel_dir="test-dir" test_package_rel_dir="test-dir"
abs_test_path="/abs/test/path" abs_test_path="/abs/test/path"
mkdir $PACKAGE_SOURCE_DIR/$test_package_rel_dir mkdir $PACKAGE_SOURCE_DIR/$test_package_rel_dir
echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0 echo "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1 echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file2 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 ] [ "$placement_index" -eq 3 ]
[ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ] [ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/file1 $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[2]}" = "$test_package_rel_dir/file2 $abs_test_path" ]
} }
@test "add_system_dir_placement adds all files in subdir to placement array" { @test "add_system_dir_placement adds all files in subdir to placement array" {
test_package_rel_dir="test-dir" test_package_rel_dir="test-dir"
test_package_rel_subdir="test-subdir" test_package_rel_subdir="test-subdir"
abs_test_path="/abs/test/path" abs_test_path="/abs/test/path"
mkdir -p $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir 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 "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 "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 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" ] [ "$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[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[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" ] [ "${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 "add_system_dir_placement adds all files in subdir and dir to placement array" {
test_package_rel_dir="test-dir" test_package_rel_dir="test-dir"
test_package_rel_subdir="test-subdir" test_package_rel_subdir="test-subdir"
abs_test_path="/abs/test/path" abs_test_path="/abs/test/path"
mkdir -p $PACKAGE_SOURCE_DIR/$test_package_rel_dir/$test_package_rel_subdir 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 "file0 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file0
echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1 echo "file1 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file1
echo "file2 contents" > $PACKAGE_SOURCE_DIR/$test_package_rel_dir/file2 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 "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 "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 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" ] [ "$placement_index" -eq "6" ]
[ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ] [ "${install_placement[0]}" = "$test_package_rel_dir/file0 $abs_test_path" ]
[ "${install_placement[1]}" = "$test_package_rel_dir/file1 $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[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[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[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" ] [ "${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" { @test "write_debian_install_file writes to debian/install" {
add_system_file_placement "somefile" "/some/abs/path" add_system_file_placement "somefile" "/some/abs/path"
write_debian_install_file write_debian_install_file
[ -f "$PACKAGE_SOURCE_DIR/debian/install" ] [ -f "$PACKAGE_SOURCE_DIR/debian/install" ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "somefile /some/abs/path" ] [ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "somefile /some/abs/path" ]
} }
@test "add_file_to_install adds file to package_dest_dir" { @test "add_file_to_install adds file to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir" local_test_dir="$BATS_TMPDIR/local-dir"
local_subdir="the/path/should/not/matter" local_subdir="the/path/should/not/matter"
package_test_dir="package-dir" package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_subdir mkdir -p $local_test_dir/$local_subdir
echo "file0 contents" > $local_test_dir/$local_subdir/file0 echo "file0 contents" > $local_test_dir/$local_subdir/file0
echo "file1 contents" > $local_test_dir/$local_subdir/file1 echo "file1 contents" > $local_test_dir/$local_subdir/file1
echo "file2 contents" > $local_test_dir/$local_subdir/file2 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/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/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/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/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ] [ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ] [ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
} }
@test "add_file_to_install added files written to install file after write_debian_install_file" { @test "add_file_to_install added files written to install file after write_debian_install_file" {
local_test_dir="$BATS_TMPDIR/local-dir" local_test_dir="$BATS_TMPDIR/local-dir"
local_subdir="the/path/should/not/matter" local_subdir="the/path/should/not/matter"
package_test_dir="package-dir" package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_subdir mkdir -p $local_test_dir/$local_subdir
echo "file0 contents" > $local_test_dir/$local_subdir/file0 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 ] [ ! -e $PACKAGE_SOURCE_DIR/debian/install ]
write_debian_install_file write_debian_install_file
[ -f $PACKAGE_SOURCE_DIR/debian/install ] [ -f $PACKAGE_SOURCE_DIR/debian/install ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "$package_test_dir/file0 $INSTALL_ROOT/$package_test_dir" ] [ "$(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" { @test "add_dir_to_install adds files in dir to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir" local_test_dir="$BATS_TMPDIR/local-dir"
package_test_dir="package-dir" package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir $local_test_dir mkdir $local_test_dir
echo "file0 contents" > $local_test_dir/file0 echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1 echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2 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/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ] [ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ] [ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ]
} }
@test "add_dir_to_install adds files in subdirectory tree to package_dest_dir" { @test "add_dir_to_install adds files in subdirectory tree to package_dest_dir" {
local_test_dir="$BATS_TMPDIR/local-dir" local_test_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir" local_test_subdir="local-subdir"
package_test_dir="package-dir" package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_test_subdir mkdir -p $local_test_dir/$local_test_subdir
echo "file0 contents" > $local_test_dir/$local_test_subdir/file0 echo "file0 contents" > $local_test_dir/$local_test_subdir/file0
echo "file1 contents" > $local_test_dir/$local_test_subdir/file1 echo "file1 contents" > $local_test_dir/$local_test_subdir/file1
echo "file2 contents" > $local_test_dir/$local_test_subdir/file2 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/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file1" ] [ -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/file2" ]
} }
@test "add_dir_to_install adds files in directory and subdirectory tree to package_dest_dir" { @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_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir" local_test_subdir="local-subdir"
package_test_dir="package-dir" package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_test_dir/$local_test_subdir mkdir -p $local_test_dir/$local_test_subdir
echo "file0 contents" > $local_test_dir/file0 echo "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1 echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2 echo "file2 contents" > $local_test_dir/file2
echo "file3 contents" > $local_test_dir/$local_test_subdir/file3 echo "file3 contents" > $local_test_dir/$local_test_subdir/file3
echo "file4 contents" > $local_test_dir/$local_test_subdir/file4 echo "file4 contents" > $local_test_dir/$local_test_subdir/file4
echo "file5 contents" > $local_test_dir/$local_test_subdir/file5 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/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ] [ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/file2" ] [ -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/file3" ]
[ -f "$PACKAGE_SOURCE_DIR/$package_test_dir/$local_test_subdir/file4" ] [ -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/$local_test_subdir/file5" ]
} }
@test "add_dir_to_install added files written to install file after write_debian_install_file" { @test "add_dir_to_install added files written to install file after write_debian_install_file" {
local_test_dir="$BATS_TMPDIR/local-dir" local_test_dir="$BATS_TMPDIR/local-dir"
package_test_dir="package-dir" package_test_dir="package-dir"
mkdir $PACKAGE_SOURCE_DIR/$package_test_dir mkdir $PACKAGE_SOURCE_DIR/$package_test_dir
mkdir -p $local_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 ] [ ! -e $PACKAGE_SOURCE_DIR/debian/install ]
write_debian_install_file write_debian_install_file
[ -f $PACKAGE_SOURCE_DIR/debian/install ] [ -f $PACKAGE_SOURCE_DIR/debian/install ]
[ "$(cat $PACKAGE_SOURCE_DIR/debian/install)" = "$package_test_dir/file0 $INSTALL_ROOT/$package_test_dir" ] [ "$(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" { @test "add_dir_to_install with empty dest dir outputs to PACKAGE_SOURCE_DIR" {
local_test_dir="$BATS_TMPDIR/local-dir" local_test_dir="$BATS_TMPDIR/local-dir"
mkdir -p $local_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" "" 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" { @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_dir="$BATS_TMPDIR/local-dir"
local_test_subdir="local-subdir" 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 "file0 contents" > $local_test_dir/file0
echo "file1 contents" > $local_test_dir/file1 echo "file1 contents" > $local_test_dir/file1
echo "file2 contents" > $local_test_dir/file2 echo "file2 contents" > $local_test_dir/file2
echo "file3 contents" > $local_test_dir/$local_test_subdir/file3 echo "file3 contents" > $local_test_dir/$local_test_subdir/file3
echo "file4 contents" > $local_test_dir/$local_test_subdir/file4 echo "file4 contents" > $local_test_dir/$local_test_subdir/file4
echo "file5 contents" > $local_test_dir/$local_test_subdir/file5 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/file0" ]
[ -f "$PACKAGE_SOURCE_DIR/file1" ] [ -f "$PACKAGE_SOURCE_DIR/file1" ]
[ -f "$PACKAGE_SOURCE_DIR/file2" ] [ -f "$PACKAGE_SOURCE_DIR/file2" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file3" ] [ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file3" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file4" ] [ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file4" ]
[ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file5" ] [ -f "$PACKAGE_SOURCE_DIR/$local_test_subdir/file5" ]
} }

View file

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