Newer
Older
dub_jkp / test / 4-describe-data-3-zero-delim.sh
@Martin Nowak Martin Nowak on 3 Jul 2017 3 KB unify flags and error handling
  1. #!/usr/bin/env bash
  2.  
  3. . $(dirname "${BASH_SOURCE[0]}")/common.sh
  4.  
  5. cd "$CURR_DIR"/describe-project
  6.  
  7. temp_file_normal=$(mktemp $(basename $0).XXXXXX)
  8. temp_file_zero_delim=$(mktemp $(basename $0).XXXXXX)
  9.  
  10. function cleanup {
  11. rm $temp_file_normal
  12. rm $temp_file_zero_delim
  13. }
  14.  
  15. trap cleanup EXIT
  16.  
  17. # Test list-style project data
  18. if ! $DUB describe --compiler=$DC --data-list \
  19. --data=target-type \
  20. --data=target-path \
  21. --data=target-name \
  22. --data=working-directory \
  23. --data=main-source-file \
  24. --data=dflags \
  25. --data=lflags \
  26. --data=libs \
  27. --data=linker-files \
  28. --data=source-files \
  29. --data=copy-files \
  30. --data=versions \
  31. --data=debug-versions \
  32. --data=import-paths \
  33. --data=string-import-paths \
  34. --data=import-files \
  35. --data=string-import-files \
  36. --data=pre-generate-commands \
  37. --data=post-generate-commands \
  38. --data=pre-build-commands \
  39. --data=post-build-commands \
  40. --data=requirements \
  41. --data=options \
  42. > "$temp_file_normal"; then
  43. die 'Printing list-style project data failed!'
  44. fi
  45.  
  46. if ! $DUB describe --compiler=$DC --data-0 --data-list \
  47. --data=target-type \
  48. --data=target-path \
  49. --data=target-name \
  50. --data=working-directory \
  51. --data=main-source-file \
  52. --data=dflags \
  53. --data=lflags \
  54. --data=libs \
  55. --data=linker-files \
  56. --data=source-files \
  57. --data=copy-files \
  58. --data=versions \
  59. --data=debug-versions \
  60. --data=import-paths \
  61. --data=string-import-paths \
  62. --data=import-files \
  63. --data=string-import-files \
  64. --data=pre-generate-commands \
  65. --data=post-generate-commands \
  66. --data=pre-build-commands \
  67. --data=post-build-commands \
  68. --data=requirements \
  69. --data=options \
  70. | xargs -0 printf "%s\n" > "$temp_file_zero_delim"; then
  71. die 'Printing null-delimited list-style project data failed!'
  72. fi
  73.  
  74. if ! diff -Z "$temp_file_normal" "$temp_file_zero_delim"; then
  75. die 'The null-delimited list-style project data did not match the expected output!'
  76. fi
  77.  
  78. # Test --import-paths
  79. if ! $DUB describe --compiler=$DC --import-paths \
  80. > "$temp_file_normal"; then
  81. die 'Printing --import-paths failed!'
  82. fi
  83.  
  84. if ! $DUB describe --compiler=$DC --data-0 --import-paths \
  85. | xargs -0 printf "%s\n" > "$temp_file_zero_delim"; then
  86. die 'Printing null-delimited --import-paths failed!'
  87. fi
  88.  
  89. if ! diff -Z -B "$temp_file_normal" "$temp_file_zero_delim"; then
  90. die 'The null-delimited --import-paths data did not match the expected output!'
  91. fi
  92.  
  93. # DMD-only beyond this point
  94. if [ "${DC}" != "dmd" ]; then
  95. echo Skipping DMD-centric tests on configuration that lacks DMD.
  96. exit
  97. fi
  98.  
  99. # Test dmd-style --data=versions
  100. if ! $DUB describe --compiler=$DC --data=versions \
  101. > "$temp_file_normal"; then
  102. die 'Printing dmd-style --data=versions failed!'
  103. fi
  104.  
  105. if ! $DUB describe --compiler=$DC --data-0 --data=versions \
  106. | xargs -0 printf "%s " > "$temp_file_zero_delim"; then
  107. die 'Printing null-delimited dmd-style --data=versions failed!'
  108. fi
  109.  
  110. if ! diff -Z "$temp_file_normal" "$temp_file_zero_delim"; then
  111. die 'The null-delimited dmd-style --data=versions did not match the expected output!'
  112. fi
  113.  
  114. # Test dmd-style --data=source-files
  115. if ! $DUB describe --compiler=$DC --data=source-files \
  116. > "$temp_file_normal"; then
  117. die 'Printing dmd-style --data=source-files failed!'
  118. fi
  119.  
  120. if ! $DUB describe --compiler=$DC --data-0 --data=source-files \
  121. | xargs -0 printf "'%s' " > "$temp_file_zero_delim"; then
  122. die 'Printing null-delimited dmd-style --data=source-files failed!'
  123. fi
  124.  
  125. if ! diff -Z "$temp_file_normal" "$temp_file_zero_delim"; then
  126. die 'The null-delimited dmd-style --data=source-files did not match the expected output!'
  127. fi