Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
640 changes: 440 additions & 200 deletions .flox/env/manifest.lock

Large diffs are not rendered by default.

34 changes: 22 additions & 12 deletions .flox/env/manifest.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
version = 1
schema-version = "1.12.0"

[install]
clang-tools.pkg-path = "clang-tools"
gcc.pkg-path = "gcc"
gdb.pkg-path = "gdb"
gnumake.pkg-path = "gnumake"
help2man.pkg-path = "help2man"
apple-sdk.pkg-path = "apple-sdk"
apple-sdk.systems = ["aarch64-darwin", "x86_64-darwin"]
coreutils.pkg-path = "coreutils"

[options]
systems = [
"aarch64-darwin",
"aarch64-linux",
"x86_64-darwin",
"x86_64-linux",
]
[hook]
# On macOS, point SDKROOT at the apple-sdk installed above so that standalone
# tools which are not run through the Nix compiler wrapper - most notably the
# clang-tidy invocation in `make lint` - can locate the system headers (e.g.
# <TargetConditionals.h>). The Platforms directory only exists on Darwin, so
# this is a no-op elsewhere and leaves the portable Makefile untouched.
on-activate = '''
sdk="$FLOX_ENV/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
if [ -d "$sdk" ]; then
export SDKROOT="$sdk"
fi
'''

[build]
t3.sandbox = "pure"
t3.runtime-packages = []
t3.command = '''
[build.t3]
sandbox = "pure"
runtime-packages = []
version.command = "git describe --tags --always --dirty"
description = "Next generation tee with colorized output streams and precise time stamping"
command = '''
make
make test
make install PREFIX=$out
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,43 @@ on:

jobs:
build:
runs-on: ubuntu-latest
# gcc 9/10/11 are only packaged for ubuntu 22.04 (jammy); the 24.04
# "ubuntu-latest" image ships gcc 12+, so pin the image to the matrix.
runs-on: ubuntu-22.04
# Bound the job so a hung stress test (the workers block on write) fails
# fast rather than running to GitHub's default job cap.
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
gcc: ['9', '10', '11']
env:
CC: gcc-${{ matrix.gcc }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y help2man clang-tidy
sudo apt-get install -y help2man clang-tidy gcc-${{ matrix.gcc }}

- name: Build
run: make
run: make CC="$CC"

- name: Run tests
run: make test
run: make test CC="$CC"

- name: Lint
run: make lint

flox-build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Install Flox
uses: flox/install-flox-action@v2
uses: flox/install-flox-action@f6002ed63e483f134001de7b4b45be891e00b09f # v2.5.1

- name: Build and Test with Flox
run: |
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# t3 build outputs
/t3
/t3.1
/result-*

# Compiled test helpers
/tests/midline-flush
/tests/stress
/tests/bench
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $(MAN1DIR)/%: %
cp $< $@
chmod 444 $@

.PHONY: all install lint clean
.PHONY: all install lint clean stress bench
all: $(BIN) $(MAN1)

install: $(INSTBIN) $(INSTMAN1)
Expand All @@ -50,15 +50,19 @@ clean:

TESTS_DIR = tests
TESTS = $(basename $(wildcard $(TESTS_DIR)/*.args))
TESTTMPDIR := $(shell mktemp -d)

# Allocate a unique scratch-directory name but do not create it: the test
# rules `mkdir -p $(TESTTMPDIR)` it on demand, so plain `make`/`make all`/
# `make install` never leave an empty temp directory behind.
TESTTMPDIR := $(shell mktemp -d -u "$${TMPDIR:-/tmp}/t3-tests.XXXXXX")
define TEST_template =
$(eval testname := $(notdir $(test)))

.INTERMEDIATE: $(test).sh
$(test).sh: $(test).args
@mkdir -p $$(TESTTMPDIR)
@echo "#!/bin/sh" > $$@
@echo -n './$$(BIN) "$$$$1" ' >> $$@
@printf '%s' './$$(BIN) "$$$$1" ' >> $$@
@cat $(test).args >> $$@
@chmod +x $$@

Expand Down Expand Up @@ -142,6 +146,30 @@ $(foreach test,$(TESTS),$(eval $(call TEST_template)))
# The partial write test depends on the compiled tests/midline-flush binary.
tests/midline-flush/run: tests/midline-flush

# Concurrency stress test: run a highly-threaded generator under t3 and verify
# that no output is dropped, duplicated, or garbled. Tunable via the command
# line, e.g. `make stress STRESS_THREADS=32 STRESS_LINES=5000`.
STRESS_THREADS ?= 16
STRESS_LINES ?= 1000

tests/stress: tests/stress.c
$(CC) $(CFLAGS) -pthread $< -o $@

stress: $(BIN) tests/stress tests/run-stress tests/check-stream.awk
@T3=./$(BIN) STRESS_THREADS=$(STRESS_THREADS) STRESS_LINES=$(STRESS_LINES) \
tests/run-stress

# Run the stress test as part of the standard `make test` suite.
test: stress

# Benchmark: estimate t3's marginal per-line overhead. Manual only - not part
# of `make test`. Tunable, e.g. `make bench COUNT=2000000 WIDTHS="32 128"`.
tests/bench: tests/bench.c
$(CC) $(CFLAGS) $< -o $@

bench: $(BIN) tests/bench tests/bench-overhead
@T3=./$(BIN) tests/bench-overhead

# Once tests are complete (and successful), remove test results.
test:
@rm -rf $(TESTTMPDIR)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ flowchart LR

```
Usage: t3 [OPTION] FILE -- COMMAND ARGS ...
Invoke provided command and write its colorized, precise time-stamped output both to the provided fileand to stdout/err.
Invoke provided command and write its colorized, precise time-stamped output both to the provided file and to stdout/err.

-l, --light use color scheme suitable for light backgrounds
-d, --dark use color scheme suitable for dark backgrounds
-b, --bold highlight stderr in bold text (with no color)
-p, --plain disable all timestamps, ANSI color and highlighting
-f, --forcecolor enforce the use of color when not writing to a TTY
-e, --errcolor color
-o, --outcolor C set the ANSI escape sequence used to color stdout
-e, --errcolor C set the ANSI escape sequence used to color stderr
-t, --ts enable timestamps in all outputs
-r, --relative display timestamps as relative offsets from start time (implies --ts)
-h, --help print this help message
Expand Down
Loading
Loading