qtsone/learning / skills/tutor
tutor
FlaggedTurn this agent into a personal programming tutor with a versioned 0-to-expert curriculum (Go available; more languages coming). Use when the user wants to learn a programming language, start or resume lessons, get their exercise code graded, check learning progress, or contribute curriculum fixes — e.g. "/tutor go", "/tutor resume", "teach me Go", "continue my lessons", "grade my exercise".
curriculum/content/focus/cli-tooling/files-processes/exercise/signal_unix_test.go
View on GitHub//go:build unix
package main
import (
"context"
"errors"
"os"
"os/signal"
"syscall"
"testing"
"time"
)
// Signal delivery is a Unix concept, so this file is built only there — the
// //go:build unix line at the top is how you keep a platform-specific test out
// of a Windows build instead of skipping it at run time.
func TestWithInterruptCancelsOnSignal(t *testing.T) {
for _, sig := range []syscall.Signal{syscall.SIGINT, syscall.SIGTERM} {
t.Run(sig.String(), func(t *testing.T) {
// The test sends the signal to itself. Registering our own channel
// first is a safety net: if WithInterrupt is not (yet) listening,
// the default action for both of these signals is to terminate the
// process, and this test binary would die rather than fail.
// Registrations do not compete — every registered channel gets a
// copy of the signal.
guard := make(chan os.Signal, 1)
signal.Notify(guard, sig)
defer signal.Stop(guard)
ctx, stop := WithInterrupt(context.Background())
defer stop()
if err := syscall.Kill(syscall.Getpid(), sig); err != nil {
t.Fatalf("sending %v to self: %v", sig, err)
}
select {
case <-ctx.Done():
case <-time.After(failsafe):
t.Fatalf("%v did not cancel the context — is WithInterrupt registered for it?", sig)
}
if !errors.Is(ctx.Err(), context.Canceled) {
t.Errorf("ctx.Err() = %v, want context.Canceled", ctx.Err())
}
})
}
}
// A signal must not abandon work in progress: the context becomes done, the
// work loop notices, and the deferred cleanup still runs. Nothing slow belongs
// in the handler itself.
func TestInterruptedWorkStillCleansUp(t *testing.T) {
guard := make(chan os.Signal, 1)
signal.Notify(guard, syscall.SIGINT)
defer signal.Stop(guard)
ctx, stop := WithInterrupt(context.Background())
defer stop()
cleaned := false
err := func() error {
defer func() { cleaned = true }()
if err := syscall.Kill(syscall.Getpid(), syscall.SIGINT); err != nil {
return err
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(failsafe):
return errors.New("SIGINT did not cancel the context")
}
}()
if !errors.Is(err, context.Canceled) {
t.Fatalf("work returned err = %v, want context.Canceled", err)
}
if !cleaned {
t.Error("cleanup did not run")
}
if got := ExitCodeFor(err); got != ExitInterrupted {
t.Errorf("ExitCodeFor(%v) = %d, want %d", err, got, ExitInterrupted)
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |