Просмотр исходного кода

Merge pull request #307 from MartinFillon/Add-more-tests

Add more unix tests and a test generator
Christina Sørensen 2 лет назад
Родитель
Сommit
d277db1c74
42 измененных файлов с 431 добавлено и 22 удалено
  1. 43 0
      devtools/generate-trycmd-test.sh
  2. 1 0
      tests/cmd/inexistant_file_unix.stderr
  3. 0 0
      tests/cmd/inexistant_file_unix.stdout
  4. 3 0
      tests/cmd/inexistant_file_unix.toml
  5. 0 0
      tests/cmd/long_binary_bytes_unix.stderr
  6. 21 0
      tests/cmd/long_binary_bytes_unix.stdout
  7. 2 0
      tests/cmd/long_binary_bytes_unix.toml
  8. 0 0
      tests/cmd/long_file_size_unix.stderr
  9. 21 0
      tests/cmd/long_file_size_unix.stdout
  10. 2 0
      tests/cmd/long_file_size_unix.toml
  11. 0 0
      tests/cmd/long_header_unix.stderr
  12. 22 0
      tests/cmd/long_header_unix.stdout
  13. 2 0
      tests/cmd/long_header_unix.toml
  14. 0 0
      tests/cmd/long_links_recurse_unix.stderr
  15. 47 0
      tests/cmd/long_links_recurse_unix.stdout
  16. 2 0
      tests/cmd/long_links_recurse_unix.toml
  17. 0 0
      tests/cmd/long_recurse_with_level_unix.stderr
  18. 21 0
      tests/cmd/long_recurse_with_level_unix.stdout
  19. 2 0
      tests/cmd/long_recurse_with_level_unix.toml
  20. 21 21
      tests/cmd/long_unix.stdout
  21. 1 1
      tests/cmd/long_unix.toml
  22. 0 0
      tests/cmd/only_dir_recursive_long_unix.stderr
  23. 21 0
      tests/cmd/only_dir_recursive_long_unix.stdout
  24. 2 0
      tests/cmd/only_dir_recursive_long_unix.toml
  25. 0 0
      tests/cmd/only_dir_recursive_unix.stderr
  26. 21 0
      tests/cmd/only_dir_recursive_unix.stdout
  27. 2 0
      tests/cmd/only_dir_recursive_unix.toml
  28. 0 0
      tests/cmd/only_dir_unix.stderr
  29. 2 0
      tests/cmd/only_dir_unix.stdout
  30. 2 0
      tests/cmd/only_dir_unix.toml
  31. 0 0
      tests/cmd/recursive_long_unix.stderr
  32. 47 0
      tests/cmd/recursive_long_unix.stdout
  33. 2 0
      tests/cmd/recursive_long_unix.toml
  34. 0 0
      tests/cmd/recursive_unix.stderr
  35. 47 0
      tests/cmd/recursive_unix.stdout
  36. 2 0
      tests/cmd/recursive_unix.toml
  37. 0 0
      tests/cmd/tree_long_unix.stderr
  38. 34 0
      tests/cmd/tree_long_unix.stdout
  39. 2 0
      tests/cmd/tree_long_unix.toml
  40. 0 0
      tests/cmd/tree_unix.stderr
  41. 34 0
      tests/cmd/tree_unix.stdout
  42. 2 0
      tests/cmd/tree_unix.toml

+ 43 - 0
devtools/generate-trycmd-test.sh

@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# Generate test data for the program
+
+if [ $# -ne 2 ]; then
+    echo "Usage: $0 <test name> <test argument>"
+    exit 1
+fi
+
+# Clean up previous test data
+
+if [ -f tests/cmd/"$1".toml ]; then
+    rm tests/cmd/"$1".toml
+fi
+
+if [ -f tests/cmd/"$1".stdout ]; then
+    rm tests/cmd/"$1".stdout
+fi
+
+if [ -f tests/cmd/"$1".stderr ]; then
+    rm tests/cmd/"$1".stderr
+fi
+
+# Generate test data
+
+touch tests/cmd/"$1".toml
+
+echo 'bin.name = "eza"' >> tests/cmd/"$1".toml
+echo 'args = "'"$2"'"' >> tests/cmd/"$1".toml
+
+# Generate expected output
+
+if [ -f target/debug/eza ]; then
+    target/debug/eza "$2" > tests/cmd/"$1".stdout 2> tests/cmd/"$1".stderr
+    returncode=$?
+    if [ $returncode -ne 0 ]; then
+        echo -e 'status.code = '$returncode'' >> tests/cmd/"$1".toml
+        exit 0
+    fi
+else
+    echo "Please build the program first"
+    exit 1
+fi

+ 1 - 0
tests/cmd/inexistant_file_unix.stderr

@@ -0,0 +1 @@
+"nonexistentdir": No such file or directory (os error 2)

+ 0 - 0
tests/cmd/inexistant_file_unix.stdout


+ 3 - 0
tests/cmd/inexistant_file_unix.toml

@@ -0,0 +1,3 @@
+bin.name = "eza"
+args = "nonexistentdir"
+status.code = 2

+ 0 - 0
tests/cmd/long_binary_bytes_unix.stderr


+ 21 - 0
tests/cmd/long_binary_bytes_unix.stdout

@@ -0,0 +1,21 @@
+ 0 a
+ 0 b
+ 0 c
+ 0 d
+ 0 e
+ - exa
+ 0 f
+ 0 g
+ 0 h
+ 0 i
+ 0 image.jpg.img.c.rs.log.png
+19 index.svg
+ 0 j
+ 0 k
+ 0 l
+ 0 m
+ 0 n
+ 0 o
+ 0 p
+ 0 q
+ - vagrant

+ 2 - 0
tests/cmd/long_binary_bytes_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --long --no-user --no-time --no-permissions --binary"

+ 0 - 0
tests/cmd/long_file_size_unix.stderr


+ 21 - 0
tests/cmd/long_file_size_unix.stdout

@@ -0,0 +1,21 @@
+ 0 a
+ 0 b
+ 0 c
+ 0 d
+ 0 e
+ - exa
+ 0 f
+ 0 g
+ 0 h
+ 0 i
+ 0 image.jpg.img.c.rs.log.png
+19 index.svg
+ 0 j
+ 0 k
+ 0 l
+ 0 m
+ 0 n
+ 0 o
+ 0 p
+ 0 q
+ - vagrant

+ 2 - 0
tests/cmd/long_file_size_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --long --no-user --no-time --no-permissions"

+ 0 - 0
tests/cmd/long_header_unix.stderr


+ 22 - 0
tests/cmd/long_header_unix.stdout

@@ -0,0 +1,22 @@
+Size Name
+   0 a
+   0 b
+   0 c
+   0 d
+   0 e
+   - exa
+   0 f
+   0 g
+   0 h
+   0 i
+   0 image.jpg.img.c.rs.log.png
+  19 index.svg
+   0 j
+   0 k
+   0 l
+   0 m
+   0 n
+   0 o
+   0 p
+   0 q
+   - vagrant

+ 2 - 0
tests/cmd/long_header_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --long --no-user --no-time --header --no-permissions"

+ 0 - 0
tests/cmd/long_links_recurse_unix.stderr


+ 47 - 0
tests/cmd/long_links_recurse_unix.stdout

@@ -0,0 +1,47 @@
+1 a
+1 b
+1 c
+1 d
+1 e
+3 exa
+1 f
+1 g
+1 h
+1 i
+1 image.jpg.img.c.rs.log.png
+1 index.svg
+1 j
+1 k
+1 l
+1 m
+1 n
+1 o
+1 p
+1 q
+5 vagrant
+
+tests/itest/exa:
+1 file.c -> djihisudjuhfius
+2 sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+
+tests/itest/exa/sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss:
+1 Makefile
+
+tests/itest/vagrant:
+2 debug
+2 dev
+3 log
+
+tests/itest/vagrant/debug:
+1 symlinking -> a
+
+tests/itest/vagrant/dev:
+1 main.bf
+
+tests/itest/vagrant/log:
+1 file.png
+2 run
+
+tests/itest/vagrant/log/run:
+1 run.log.text
+1 sps.log.text

+ 2 - 0
tests/cmd/long_links_recurse_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --long --no-user --no-time --no-filesize --no-permissions --recurse --links"

+ 0 - 0
tests/cmd/long_recurse_with_level_unix.stderr


+ 21 - 0
tests/cmd/long_recurse_with_level_unix.stdout

@@ -0,0 +1,21 @@
+a
+b
+c
+d
+e
+exa
+f
+g
+h
+i
+image.jpg.img.c.rs.log.png
+index.svg
+j
+k
+l
+m
+n
+o
+p
+q
+vagrant

+ 2 - 0
tests/cmd/long_recurse_with_level_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --long --no-user --no-permissions --no-time --no-filesize --recurse --level 2"

+ 21 - 21
tests/cmd/long_unix.stdout

@@ -1,21 +1,21 @@
-.rw-r--r-- a
-.rw-r--r-- b
-.rw-r--r-- c
-.rw-r--r-- d
-.rw-r--r-- e
-drwxr-xr-x exa
-.rw-r--r-- f
-.rw-r--r-- g
-.rw-r--r-- h
-.rw-r--r-- i
-.rw-r--r-- image.jpg.img.c.rs.log.png
-.rw-r--r-- index.svg
-.rw-r--r-- j
-.rw-r--r-- k
-.rw-r--r-- l
-.rw-r--r-- m
-.rw-r--r-- n
-.rw-r--r-- o
-.rw-r--r-- p
-.rw-r--r-- q
-drwxr-xr-x vagrant
+a
+b
+c
+d
+e
+exa
+f
+g
+h
+i
+image.jpg.img.c.rs.log.png
+index.svg
+j
+k
+l
+m
+n
+o
+p
+q
+vagrant

+ 1 - 1
tests/cmd/long_unix.toml

@@ -1,2 +1,2 @@
 bin.name = "eza"
-args = "tests/itest --long --no-user --no-time --no-filesize"
+args = "tests/itest --long --no-user --no-time --no-filesize --no-permissions"

+ 0 - 0
tests/cmd/only_dir_recursive_long_unix.stderr


+ 21 - 0
tests/cmd/only_dir_recursive_long_unix.stdout

@@ -0,0 +1,21 @@
+exa
+vagrant
+
+tests/itest/exa:
+sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+
+tests/itest/exa/sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss:
+
+tests/itest/vagrant:
+debug
+dev
+log
+
+tests/itest/vagrant/debug:
+
+tests/itest/vagrant/dev:
+
+tests/itest/vagrant/log:
+run
+
+tests/itest/vagrant/log/run:

+ 2 - 0
tests/cmd/only_dir_recursive_long_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --recurse --long --no-user --no-time --no-filesize --no-permissions --only-dirs"

+ 0 - 0
tests/cmd/only_dir_recursive_unix.stderr


+ 21 - 0
tests/cmd/only_dir_recursive_unix.stdout

@@ -0,0 +1,21 @@
+exa
+vagrant
+
+tests/itest/exa:
+sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+
+tests/itest/exa/sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss:
+
+tests/itest/vagrant:
+debug
+dev
+log
+
+tests/itest/vagrant/debug:
+
+tests/itest/vagrant/dev:
+
+tests/itest/vagrant/log:
+run
+
+tests/itest/vagrant/log/run:

+ 2 - 0
tests/cmd/only_dir_recursive_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --only-dirs --recurse"

+ 0 - 0
tests/cmd/only_dir_unix.stderr


+ 2 - 0
tests/cmd/only_dir_unix.stdout

@@ -0,0 +1,2 @@
+exa
+vagrant

+ 2 - 0
tests/cmd/only_dir_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --only-dirs"

+ 0 - 0
tests/cmd/recursive_long_unix.stderr


+ 47 - 0
tests/cmd/recursive_long_unix.stdout

@@ -0,0 +1,47 @@
+a
+b
+c
+d
+e
+exa
+f
+g
+h
+i
+image.jpg.img.c.rs.log.png
+index.svg
+j
+k
+l
+m
+n
+o
+p
+q
+vagrant
+
+tests/itest/exa:
+file.c -> djihisudjuhfius
+sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+
+tests/itest/exa/sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss:
+Makefile
+
+tests/itest/vagrant:
+debug
+dev
+log
+
+tests/itest/vagrant/debug:
+symlinking -> a
+
+tests/itest/vagrant/dev:
+main.bf
+
+tests/itest/vagrant/log:
+file.png
+run
+
+tests/itest/vagrant/log/run:
+run.log.text
+sps.log.text

+ 2 - 0
tests/cmd/recursive_long_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --recurse --long --no-user --no-time --no-filesize --no-permissions"

+ 0 - 0
tests/cmd/recursive_unix.stderr


+ 47 - 0
tests/cmd/recursive_unix.stdout

@@ -0,0 +1,47 @@
+a
+b
+c
+d
+e
+exa
+f
+g
+h
+i
+image.jpg.img.c.rs.log.png
+index.svg
+j
+k
+l
+m
+n
+o
+p
+q
+vagrant
+
+tests/itest/exa:
+file.c -> djihisudjuhfius
+sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+
+tests/itest/exa/sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss:
+Makefile
+
+tests/itest/vagrant:
+debug
+dev
+log
+
+tests/itest/vagrant/debug:
+symlinking -> a
+
+tests/itest/vagrant/dev:
+main.bf
+
+tests/itest/vagrant/log:
+file.png
+run
+
+tests/itest/vagrant/log/run:
+run.log.text
+sps.log.text

+ 2 - 0
tests/cmd/recursive_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --recurse"

+ 0 - 0
tests/cmd/tree_long_unix.stderr


+ 34 - 0
tests/cmd/tree_long_unix.stdout

@@ -0,0 +1,34 @@
+tests/itest
+├── a
+├── b
+├── c
+├── d
+├── e
+├── exa
+│  ├── file.c -> djihisudjuhfius
+│  └── sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+│     └── Makefile
+├── f
+├── g
+├── h
+├── i
+├── image.jpg.img.c.rs.log.png
+├── index.svg
+├── j
+├── k
+├── l
+├── m
+├── n
+├── o
+├── p
+├── q
+└── vagrant
+   ├── debug
+   │  └── symlinking -> a
+   ├── dev
+   │  └── main.bf
+   └── log
+      ├── file.png
+      └── run
+         ├── run.log.text
+         └── sps.log.text

+ 2 - 0
tests/cmd/tree_long_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --tree --long --no-user --no-time --no-filesize --no-permissions"

+ 0 - 0
tests/cmd/tree_unix.stderr


+ 34 - 0
tests/cmd/tree_unix.stdout

@@ -0,0 +1,34 @@
+tests/itest
+├── a
+├── b
+├── c
+├── d
+├── e
+├── exa
+│  ├── file.c -> djihisudjuhfius
+│  └── sssssssssssssssssssssssssggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
+│     └── Makefile
+├── f
+├── g
+├── h
+├── i
+├── image.jpg.img.c.rs.log.png
+├── index.svg
+├── j
+├── k
+├── l
+├── m
+├── n
+├── o
+├── p
+├── q
+└── vagrant
+   ├── debug
+   │  └── symlinking -> a
+   ├── dev
+   │  └── main.bf
+   └── log
+      ├── file.png
+      └── run
+         ├── run.log.text
+         └── sps.log.text

+ 2 - 0
tests/cmd/tree_unix.toml

@@ -0,0 +1,2 @@
+bin.name = "eza"
+args = "tests/itest --tree"