Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,25 @@ jobs:
run: |
tar xzf try-dist.tgz/try-*.tgz --strip-components=1
rm -r try-dist.tgz
./configure
./configure --disable-utils
make all
sudo make install

- name: Run tests with shell fallbacks
run: |
! which try-summary
! which try-commit
scripts/run_tests.sh

- name: Clean up build
run: |
sudo make clean

- name: Install utilities
run: |
autoconf
./configure
make all
sudo make install

- name: Run tests with utilities
Expand Down Expand Up @@ -116,17 +124,25 @@ jobs:
- name: Configure and build utilities
run: |
autoconf
./configure
./configure --disable-utils
make all
sudo make install

- name: Run tests with shell fallbacks
run: |
! which try-summary
! which try-commit
scripts/run_tests.sh

- name: Clean up build
run: |
sudo make clean

- name: Install utilities
run: |
autoconf
./configure
make all
sudo make install

- name: Run tests with utilities
Expand Down
8 changes: 6 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ INSTALL=@INSTALL@
DISTDIR=@PACKAGE_TARNAME@-@PACKAGE_VERSION@
DISTTGZ=$(DISTDIR).tgz

TARGETS=$(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) man/try.1.gz
TARGETS=utils/make-socket $(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) man/try.1.gz

all: $(TARGETS)

install: $(TARGETS)
$(INSTALL) -d $(bindir)
$(INSTALL) -m 755 try $(bindir)
$(INSTALL) -m 755 utils/make-socket $(bindir)
ifeq (@enable_utils@, yes)
$(INSTALL) -m 755 utils/try-summary $(bindir)
$(INSTALL) -m 755 utils/try-commit $(bindir)
Expand Down Expand Up @@ -58,7 +59,10 @@ utils/try-summary: utils/ignores.o utils/try-summary.o
utils/try-commit: utils/ignores.o utils/try-commit.o
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -g $^

test: try $(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit)
utils/make-socket: utils/make-socket.o
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -g $^

test: try $(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) utils/make-socket
scripts/run_tests.sh

lint:
Expand Down
30 changes: 30 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ Vagrant.configure("2") do |config|
sudo apt-get update
sudo apt-get install -y git expect curl attr pandoc gcc make autoconf mergerfs
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try

autoconf && ./configure --disable-utils
Comment thread
mgree marked this conversation as resolved.
Outdated
make
sudo make install
scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand Down Expand Up @@ -78,10 +85,15 @@ Vagrant.configure("2") do |config|
# This is intentional, if we moved try to lv1 it'd work since itself does not contain a nested mount
sudo mv /home/vagrant/try /mnt/lv0
sudo chown -R vagrant:vagrant /mnt/lv0/try
sudo modprobe overlay

cd /mnt/lv0/try
autoconf && ./configure --disable-utils && make
sudo make install
scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand All @@ -97,6 +109,7 @@ Vagrant.configure("2") do |config|
sudo apt-get update
sudo apt-get install -y curl attr pandoc gcc make autoconf mergerfs zsh
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try


Expand Down Expand Up @@ -149,8 +162,18 @@ Vagrant.configure("2") do |config|
wget https://github.com/trapexit/mergerfs/releases/download/2.40.2/mergerfs-2.40.2-1.el9.x86_64.rpm
sudo rpm -i mergerfs-2.40.2-1.el9.x86_64.rpm
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try

autoconf && ./configure --disable-utils && make
Comment thread
mgree marked this conversation as resolved.
Outdated
sudo make install

autoconf && ./configure --disable-utils && make
sudo make install
TRY_TOP=$(pwd) scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand All @@ -167,8 +190,15 @@ Vagrant.configure("2") do |config|
wget https://github.com/trapexit/mergerfs/releases/download/2.40.2/mergerfs-2.40.2-1.fc39.x86_64.rpm
sudo rpm -i mergerfs-2.40.2-1.fc39.x86_64.rpm
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try

autoconf && ./configure --disable-utils && make
sudo make install
TRY_TOP=$(pwd) scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand Down
28 changes: 17 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@ AC_ARG_ENABLE([utils],
[don't compile C utilities for summarizing and committing changes (default is yes)])],
[enable_utils=${enableval}], [enable_utils=yes])


AC_REQUIRE_AUX_FILE([utils/make-socket.c])

# build tools
AC_PROG_CC

# CFLAGS AND CPPFLAGGS
if test -z "$CFLAGS"
then
AUTO_CFLAGS="-g -Wall -O2"
AUTO_CPPFLAGS="-g -Wall -O2"
Comment thread
mgree marked this conversation as resolved.
Outdated
else
AUTO_CFLAGS=""
AUTO_CPPFLAGS=""
fi

if test "$enable_utils" = "yes"
then
AC_REQUIRE_AUX_FILE([utils/try-commit.c])

# build tools
AC_PROG_CC

# CFLAGS and CPPFLAGGS
if test -z "$CFLAGS"
then
AUTO_CFLAGS="-g -Wall -O2"
else
AUTO_CFLAGS=""
fi
AUTO_CPPFLAGS=""
AUTO_CPPFLAGS=""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go now, since we've set it unconditionally above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is still active---no need to set AUTO_CPPFLAGS here.


CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
Comment thread
mgree marked this conversation as resolved.
CPPFLAGS=${CPPFLAGS-"$AUTO_CPPFLAGS"}
Expand Down
8 changes: 2 additions & 6 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ stdenv.mkDerivation {
pname = "try";
version = "latest";

src = fetchFromGitHub {
owner = "binpash";
repo = "try";
rev = "67052d8f20725f3cdc22ffaec33f7b7c14f1eb6b";
hash = "sha256-8mfCmqN50pRAeNTJUlRVrRQulWon4b2OL4Ug/ygBhB0=";
};
src = ./.;

# skip TRY_REQUIRE_PROG as it detects executable dependencies by running it
postPatch = ''
Expand All @@ -40,6 +35,7 @@ stdenv.mkDerivation {
install -Dt $out/bin try
install -Dt $out/bin utils/try-commit
install -Dt $out/bin utils/try-summary
install -Dt $out/bin utils/make-socket
wrapProgram $out/bin/try --prefix PATH : ${
lib.makeBinPath [
coreutils
Expand Down
2 changes: 1 addition & 1 deletion scripts/check_trycase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ check_file() {
lf="${lf%)}"

case "$cf" in
(file|dir|symlink|nonexist|opaque|whiteout);;
(file|dir|symlink|nonexist|opaque|whiteout|fifo|socket);;
(*) printf "ERROR: $1: invalid changed file: %s\n" "$cf"
: $((ERRORS += 1))
;;
Expand Down
93 changes: 85 additions & 8 deletions test/all-commit-cases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-
TRY="$TRY_TOP/try"

cleanup() {
cd /
cd /
Comment thread
mgree marked this conversation as resolved.
Outdated

if [ -d "$try_workspace" ]
then
rm -rf "$try_workspace" >/dev/null 2>&1
fi
if [ -d "$try_workspace" ]; then
rm -rf "$try_workspace" >/dev/null 2>&1
fi
}

trap 'cleanup' EXIT
Expand All @@ -25,11 +24,10 @@ cd "$try_workspace" || exit 99

COUNT=0
fail() {
echo Case $COUNT: "$@"
exit ${COUNT}
echo Case $COUNT: "$@"
exit ${COUNT}
}


# // TRYCASE(opaque, dir)
# // TRYCASE(dir, dir)

Expand Down Expand Up @@ -224,3 +222,82 @@ echo arrivederci >formerdir/it/file2 || fail
[ -L formerdir ] || fail
[ "$(readlink formerdir)" = "/this/is/a/broken/symlink" ] || fail
rm formerdir || fail

# // TRYCASE(fifo, file)

: $((COUNT += 1))

! [ -e newpipe ] || fail
"$TRY" -y "mkfifo newpipe; rm newpipe; touch newpipe; echo new >newpipe"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not test the declared case (new file is a fifo, old file is a regular file).

[ -f newpipe ] || fail
[ "$(cat newpipe)" = "new" ] || fail
rm newpipe || fail

# // TRYCASE(fifo, dir)

: $((COUNT += 1))

! [ -e newpipe ] || fail
"$TRY" -y "mkfifo newpipe; rm newpipe; mkdir newpipe"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not test the declared case---the newpipe file doesn't exist, when it ought to first be a directory.

[ -d newpipe ] || fail
rm -r newpipe

# // TRYCASE(fifo, symlink)

: $((COUNT += 1))

! [ -e newpipe ] || fail
ln -s "$TRY" newpipe
[ -L newpipe ] || fail
"$TRY" -y "rm newpipe; mkfifo newpipe"
[ -p newpipe ] || fail
rm newpipe

# // TRYCASE(fifo, nonexist)

: $((COUNT += 1))

! [ -e newpipe ] || fail
"$TRY" -y "mkfifo newpipe"
[ -p newpipe ] || fail
rm newpipe

# // TRYCASE(socket, file)

: $((COUNT += 1))

! [ -e newsock ] || fail
Comment thread
mgree marked this conversation as resolved.
"$TRY" -y "make-socket newsock; rm newsock; touch newsock; echo hello> newsock"
[ -f newsock ] || fail
[ "$(cat newsock)" = "hello" ] || fail
rm newsock

# // TRYCASE(socket, dir)

: $((COUNT += 1))

! [ -e newsock ] || fail
Comment thread
mgree marked this conversation as resolved.
"$TRY" -y "make-socket newsock; rm newsock; mkdir newsock"
[ -d newsock ] || fail
rm -r newsock

# // TRYCASE(socket, symlink)

: $((COUNT += 1))

! [ -e newsock ] || fail
ln -s "$TRY" newsock
[ -L newsock ] || fail
"$TRY" -y "rm newsock; make-socket newsock"
! [ -e newlink ] || fail
[ -S newsock ] || fail
rm newsock

# // TRYCASE(socket, nonexist)

: $((COUNT += 1))

! [ -e newsock ]
"$TRY" -y "make-socket newsock"
[ -S newsock ] || fail
rm newsock
Loading
Loading