78 Commits

Author SHA1 Message Date
Peter Dave Hello
aff6fb4ac9 Syntax highlight in readme.md 2017-03-16 04:36:40 +08:00
Thomas Levine
9721f976e0 organize files 2016-04-11 18:44:58 +00:00
Thomas Levine
65dba9697d update history 2016-04-11 18:44:53 +00:00
Thomas Levine
f57e6cca22 move packages 2016-04-11 18:42:39 +00:00
Thomas Levine
144a76319c remove & 2016-04-11 18:42:33 +00:00
Thomas Levine
cb4e16ddff limits 2016-04-11 17:53:31 +00:00
Thomas Levine
cbad100692 more packages 2016-04-11 17:44:14 +00:00
Thomas Levine
3d5b5ede46 container 2016-04-11 17:40:56 +00:00
Thomas Levine
aedaaa3a05 ssh 2016-04-11 17:28:05 +00:00
Thomas Levine
5045b3546f fix configuration 2016-04-11 17:22:06 +00:00
Thomas Levine
9514948636 nixos-container 2016-04-11 17:14:12 +00:00
Thomas Levine
81a611dd9b require test 2016-04-11 16:27:38 +00:00
Thomas Levine
6fea07d8cf recurse 2016-04-11 16:20:20 +00:00
Thomas Levine
bd4d06bef6 explosions... 2016-04-11 05:44:58 +00:00
Thomas Levine
d92a9bc801 descend directories 2016-04-11 05:05:39 +00:00
Thomas Levine
dc90ed8578 merge small functions 2016-04-11 04:48:26 +00:00
Thomas Levine
d9ffa53e25 debug 2016-04-11 04:31:15 +00:00
Thomas Levine
47860e56ce local variables 2016-04-11 04:13:05 +00:00
Thomas Levine
37e57773a6 NO_MAIN variable 2016-04-11 04:04:30 +00:00
Thomas Levine
c8a0a1b30e meta 2016-04-10 22:48:55 +00:00
Thomas Levine
1bf8b930ec organize metafunctions better 2016-04-10 22:45:39 +00:00
Thomas Levine
a7a5db1cfd more meta 2016-04-10 22:44:22 +00:00
Thomas Levine
85a6c37dfc catch exit codes better 2016-04-10 22:07:15 +00:00
Thomas Levine
ba20619102 names 2016-04-10 21:55:15 +00:00
Thomas Levine
9932d0bf6f read -r and stuff 2016-04-10 21:54:08 +00:00
Thomas Levine
25f74b68cf localpath 2016-04-10 21:45:37 +00:00
Thomas Levine
2bd752012c localpath 2016-04-10 21:27:04 +00:00
Thomas Levine
3761493c7c $ for clarity 2016-04-10 21:18:08 +00:00
Thomas Levine
51fa9dc879 localpath 2016-04-10 21:17:19 +00:00
Thomas Levine
de4a92de7a simpler return codes for recurse 2016-04-10 21:05:34 +00:00
Thomas Levine
9bc3d63ded grr 2016-04-10 20:45:01 +00:00
Thomas Levine
4ca5b98550 comparators 2016-04-10 20:36:05 +00:00
Thomas Levine
fad04e1584 nicer cleanup 2016-04-10 20:34:36 +00:00
Thomas Levine
af0a80d1bd outline main 2016-04-10 20:27:56 +00:00
Thomas Levine
cc2c60cac0 remove another file 2016-04-10 20:11:40 +00:00
Thomas Levine
f3f01bb0dc input parsing 2016-04-10 20:05:34 +00:00
Thomas Levine
8a234e687f remove cycling 2016-04-10 20:03:07 +00:00
Thomas Levine
a6aaa5a130 header 2016-04-10 19:53:57 +00:00
Thomas Levine
3a4a7012a7 refactoring 2016-04-10 19:51:21 +00:00
Thomas Levine
a97bb751bc skip better 2016-04-10 19:44:17 +00:00
Thomas Levine
e217d5a8fb skip encoding 2016-04-10 19:39:11 +00:00
Thomas Levine
2ba4c8b00e exit codes 2016-04-10 19:32:01 +00:00
Thomas Levine
b03640f8aa shell test as variable rather than list 2016-04-10 19:27:15 +00:00
Thomas Levine
7e7b661c68 shorter 2016-04-10 19:20:04 +00:00
Thomas Levine
4e3e29c159 exit codes 2016-04-10 19:17:02 +00:00
Thomas Levine
9caa0d1225 more format 2016-04-10 19:08:19 +00:00
Thomas Levine
f4b66881f6 refactor 2016-04-10 18:56:32 +00:00
Thomas Levine
7dc70982e5 shorter outcome printing 2016-04-10 18:51:52 +00:00
Thomas Levine
34a6276b20 move footer 2016-04-10 18:43:58 +00:00
Thomas Levine
4db468ef2e colors 2016-04-10 18:42:58 +00:00
Thomas Levine
3ceba43410 start rearranging formatting 2016-04-10 18:23:24 +00:00
Thomas Levine
deaf05c062 log format 2016-04-10 17:53:11 +00:00
Thomas Levine
0feeb7233b tabs 2016-04-10 17:42:20 +00:00
Thomas Levine
562489e795 read with -d (not standard) 2016-04-10 17:18:32 +00:00
Thomas Levine
a084577951 play with reading many args 2016-04-10 17:04:12 +00:00
Thomas Levine
22e9f57f0f relative potential test in log file 2016-04-10 16:49:14 +00:00
Thomas Levine
246f29f06c wrappers 2016-04-10 16:40:36 +00:00
Thomas Levine
e230a80be1 move argument validation to the parser 2016-04-10 16:12:40 +00:00
Thomas Levine
b3188d17fc parameter expansions 2016-04-10 16:03:57 +00:00
Thomas Levine
446353a6a7 parameter expansions 2016-04-10 16:02:23 +00:00
Thomas Levine
287fd8a37c use new contains 2016-04-10 15:50:29 +00:00
Thomas Levine
9ce5c45bed "contains" function 2016-04-10 15:48:30 +00:00
Thomas Levine
f01c7f9b53 move dependency checks up to beginning 2016-04-10 15:34:06 +00:00
Thomas Levine
015dd2894f move validation lower 2016-04-10 09:05:08 +00:00
Thomas Levine
4798611d78 ascii delimiters 2016-04-10 08:45:11 +00:00
Thomas Levine
478b0b3c8d ideas 2016-04-10 06:36:34 +00:00
Thomas Levine
fa4708f940 command -v 2016-04-10 06:15:55 +00:00
Thomas Levine
77aff50374 print head 2016-04-10 06:05:28 +00:00
Thomas Levine
0ee97569a6 new format variable 2016-04-10 06:04:12 +00:00
Thomas Levine
f783aa8cbf Automatic commit with j 2016-04-08 22:44:29 +00:00
Thomas Levine
b807f6ad70 version 2016-04-08 22:29:50 +00:00
Thomas Levine
3cfa308953 order matter 2016-04-08 22:25:58 +00:00
Thomas Levine
b46d1a9d6c rearrange contents of the file 2016-04-08 22:24:55 +00:00
Thomas Levine
4608827fed document remote test-running 2016-04-08 21:10:01 +00:00
Thomas Levine
e36333a6c6 document remote test-running 2016-04-08 21:09:59 +00:00
Thomas Levine
c99f6f2919 document remote test-running 2016-04-08 21:09:57 +00:00
Thomas Levine
0227fc73f4 document remote test-running 2016-04-08 21:09:47 +00:00
Thomas Levine
a5e63f5042 execution with remotes 2016-04-08 20:41:53 +00:00
11 changed files with 797 additions and 626 deletions

View File

@@ -1,10 +1,8 @@
HISTORY
=======
Version 0.1.0
Version 0.2.0 (unstable)
---------------------
This release includes breaking changes.
### Cross-OS testing
I have started testing Urchin across multiple operating systems.
This gives access to more shells, as some shels are easier to install on
@@ -13,6 +11,10 @@ certain operating systems.
With this cross-OS test suite, I have extended support to more shells.
A later version of Urchin could include a remote testing feature.
Version 0.1.0 (stable)
---------------------
This release includes breaking changes.
### Test root directory
We introduce a concept of the root directory of a test suite.
Such a concept is important in case you want to run subsets of your

14
TODO
View File

@@ -278,3 +278,17 @@ NetBSD
Things I can use to make things better
------------------------
${x##*blah}
$IFS and set --
Redirection, especiall <<-
Maybe fifo
for x in "$@"
until
readonly
getopts
Variable assignments specified with special built-in utilities remain in
effect after the built-in completes; this shall not be the case with a
regular built-in or other utility.

109
docs/execution-flow Normal file
View File

@@ -0,0 +1,109 @@
Here I discuss Urchin's general execution flow and how it is handled
specifically when tests are run on remote environments.
Steps of an Urchin run
----------------------
When Urchin runs a directory of files, it goes through the following
steps.
1. Head
2. Test
3. Foot
4. Reporting
Urchin stores files in a temporary directory, creating a new directory
on each invocation. The directory contains these things.
* head (file)
* test (file)
* foot (file)
* stdout (directory)
When run on remotes, the temporary directory corresponding to the local
master process additionally has these files.
* remote-test
Messages from the head, test, and foot steps go in the corresponding
files. In the head and foot phases, messages are just simple prints.
Messages from the test phase always correspond to a particular test
file, and they are written to the test file in a delimiter-separated
format.
Stdout and stderr from test runs are written to files in the stdout
directory, one file per test file per shell that the file is run in.
The reporting phase
----------------------
In most cases Urchin begins printing to the screen only during the
reporting phase. The only case where anything is printed beforehand is
when Urchin is run with -vvvv; that sets "+x", so the commands are
printed as they run, though all other output is still suppressed.
Test results are reported in the reporting phase. Four output formats
are available.
1. Urchin's human-readable format (default)
2. Test Anything Protocol
3. Delimiter-separated values (used internally)
4. Remote Urchin worker output
Most of the output is generated based on the delimiter-separated values
in the test log file. The first two formats also include stdout and
stderr from the tests, depending on verbosity level flags; when it needs
these, Urchin reads them from appropriate files in the temporary
directory.
I could discuss the further details of each format elsewhere.
Remotes
----------------------
When Urchin runs tests on a remote, it copies tests to the remote and
then calls Urchin on the remote with "--format=remote". This specifies
the following.
* The temporary directory should be kept, rather than deleted, after
Urchin runs.
* The path of the temporary directory should be printed as output.
* No other output should be printed to stdout.
After the remote Urchin finishes running, the local urchin downloads
the remote Urchin's test log file from the temporary directory.
It modifies the file to include the remote's name and then concatenates
the result to the "remote-test" file in the local temporary directory.
For example, the file from the remote might look like this,
:sh:Counting tests/.test/faila:0:not_ok
and the result might look like this.
nsa:sh:Counting tests/.test/faila:0:not_ok
This gets processed in the reporting step like usual, according to
whatever format is specified. Instead of printing just "sh" as the
environment in which the particular test was run, the report will print
"sh on nsa".
When it needs the stdout files, it prints them over ssh.
New flags
----------
In making this remotes feature, I wound up adding some others.
-r, --remote SSH host to use as a remote
-F, --format Output format, one of "urchin", "tap", "dsv", "remote"
Urchin runs only locally by default. If you pass at least one --remote
flag, Urchin runs tests only on the specified remotes; it can't run both
locally and remotely in the same run. If you want to do that, you could
wait until I add that feature, or you can add "localhost" as a remote.
Settings that I'm thinking about
* Port for rsync/ssh
* SSH protocol version
* --rsync-path
Can those all be set in ssh_config? Probably not --rsync-path, but
I guess I could just fix it on the remote.

View File

@@ -0,0 +1,39 @@
# A NixOS container to protect against accidental fork bombs
#
# Put this in /var/lib/containers/test/etc/nixos/configuration.nix
# See https://nixos.org/wiki/NixOS:Containers
{ config, lib, pkgs, ... }:
with lib;
{ boot.isContainer = true;
networking.hostName = mkDefault "urchin";
networking.useDHCP = false;
environment.systemPackages = with pkgs; [
# Urchin
bash dash mksh zsh
busybox
# Other
vim git rsync tmux
];
security.pam.loginLimits = [
# Prevent accidental fork bombs.
{ domain = "*"; item = "nproc"; type = "hard"; value = "200"; }
];
services.openssh = {
enable = true;
passwordAuthentication = false;
};
users.extraUsers.user = {
name = "tlevine";
uid = 1000;
isNormalUser = true;
home = "/home/tlevine";
extraGroups = [ "users" "wheel" ];
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGvQyzr42/96acUTUedaeM2ee+DMt9bkxeurdeXji9sNE10MjjAUFtxPmSI8/BUZW2/a9ByblfaJEI+H+kFVPjVr+QGKXZluxcFMj2BLbH53fi9xLgoQRjb2aAXutb2Bp74/E8R1K+CuFfRRGQ5Spdnv44SLt04D6JbBLcLIcWTpQ4v5RaYr2U27jfiF9z0m+/opxvowEy2gnqlEXFxFk8jZHT4K0uLWm2ENjT6OpyOx8hWcKeAN2vRVRex3pJfSzswn0LpuCrM1rUZ4DRE+FABi8N21Q3MBaMRkwnZPwaZwKzv06q8bu23jYTqK5BrUPtOXeeVuroQXMc12H/6/Nh laptop"
];
};
}

View File

@@ -0,0 +1,36 @@
#!/bin/sh
set -e
# Create the container.
if ! nixos-container list | grep ^urchin$ > /dev/null; then
sudo nixos-container create urchin
fi
# Configure the container.
sudo cp configuration.nix \
/var/lib/containers/urchin/etc/nixos/configuration.nix
sudo nixos-container update urchin
sudo nixos-container start urchin
# Create the git repository.
host="tlevine@$(nixos-container show-ip urchin)"
ssh "${host}" 'if mkdir urchin 2> /dev/null; then
cd urchin
git init
git config --add receive.denyCurrentBranch ignore
fi
'
# Push to the git repository
git push "${host}":urchin
# Print information
echo "Log in:
ssh ${host}
Add git remote
git remote add ${host} container
"

View File

@@ -21,8 +21,10 @@ is like. Clone the repository
Run the tests
cd urchin
./urchin tests
```sh
cd urchin
./urchin tests
```
## Dependencies
Urchin depends on the following programs.
@@ -50,9 +52,11 @@ of these programs.
Urchin is contained in a single file, so you can install it by copying it to a
directory in your `PATH`. For example, you can run the following as root.
cd /usr/local/bin
wget https://raw.githubusercontent.com/tlevine/urchin/v0.1.0-rc3/urchin
chmod +x urchin
```sh
cd /usr/local/bin
wget https://raw.githubusercontent.com/tlevine/urchin/v0.1.0-rc3/urchin
chmod +x urchin
```
Urchin can be installed with npm too.
@@ -110,9 +114,11 @@ directory tree. The test passes if the file exits 0; otherwise, it fails.
urchin looks for files within a directory in the following manner,
for file in *; do
do_something_with_test_file $file
done
```sh
for file in *; do
do_something_with_test_file $file
done
```
so files are run in whatever order `*` produces. The order is
configured in your environment, at least in
@@ -125,18 +131,20 @@ order the tests ran in.
Below you can see how the locale can affect the order.
$ printf '!c\n@a\n~b\n' | LC_COLLATE=C sort
!c
@a
~b
$ printf '!c\n@a\n~b\n' | LC_COLLATE=en_US.UTF-8 sort
@a
~b
!c
$ printf '!c\n@a\n~b\n' | sort -d
@a
~b
!c
```sh
$ printf '!c\n@a\n~b\n' | LC_COLLATE=C sort
!c
@a
~b
$ printf '!c\n@a\n~b\n' | LC_COLLATE=en_US.UTF-8 sort
@a
~b
!c
$ printf '!c\n@a\n~b\n' | sort -d
@a
~b
!c
```
### Writing cross-shell compatibility tests for testing shell code

View File

@@ -1,3 +1,3 @@
echo "$1" > $tmp
TESTING_URCHIN_INTERNALS=true . ../../../urchin
NO_MAIN= . ../../../urchin
has_shebang_line $tmp

1167
urchin

File diff suppressed because it is too large Load Diff