Oil Dev Cheat Sheet - oilshell/oil Wiki

The Contributing page walks you through the dev tools.

Here is a list of commands I often run.

IMPORTANT: source devtools/completion.bash gives you completion for the "two level structure" of shell files and functions. You can hit tab and then it will complete function names. (TODO: There is some flakiness if you hit tab in the wrong place, but it generally works. #797).

Oil in Python

build/dev.sh all  # create the dev build

bin/osh -c 'echo hi'  # directly run dev build

test/unit.sh all  # run all Python unit tests

test/spec.sh smoke  # run a single test suite

test/spec.sh smoke -r 0 -v  # run a single test 

test/spec.sh osh-all  # run all OSH spec tests

test/spec.sh oil-all  # run all Oil spec tests

Static Checks

types/oil-slice.sh soil-run  # check types with MyPy

test/lint.sh soil-run  # Python linter (not fast!)

oil-native (C++)

build/dev.sh oil-cpp  # translate Python to C++, and compile oil-native

_bin/cxx-dbg/osh_eval -c 'echo hi'  # directly run oil-native

./NINJA_config.py  # generate build.ninja and ./TASK.sh

ninja _bin/cxx-dbg/osh_eval  # just compile, don't translate

ninja _bin/cxx-opt/osh_eval.stripped  # compile optimized build

build/native.sh compile-quickly  # compile quickly with a copy of Clang

test/spec-cpp.sh run-with-osh-eval smoke  # run a single suite against oil-native

test/spec-cpp.sh run-with-osh-eval smoke -r 0 -v  # as above

test/spec-cpp.sh all  # run all OSH tests with C++

test/lint.sh format-oil  # reformat the C++ code.  'git diff' to see the result.
                         # requires Clang from soil/deps-binary.sh download-clang

mycpp

ninja mycpp-all  # run big mycpp-examples test matrix

ninja -j 1 mycpp-all  # run serially to isolate last failure

ninja -t targets all | sort  # list hundreds of targets (variants).  Use with grep.

./TASK.sh list  # list unit tests managed by Ninja

# build run a single unit test.  This file is generated by NINJA_config.py.
./TASK.sh mycpp-gc_heap_test.debug

# run 3 unit tests that aren't in Ninja.  We don't have fine-grained deps yet.
test/cpp-unit.sh all  

PYTHONPATH=. mycpp/examples/parse.py      # run python example directly
_test/bin/examples/parse.asan             # run C++ translation
BENCHMARK=1 _test/bin/examples/parse.opt  # run optimized binary in benchmark mode


# Run a Ninja task.  The task file is "demanded" to run the examples/length.py file.
# TODO: the dependencies are a little weird here

rm _test/tasks/test/length.py.task.txt
ninja _test/tasks/test/length.py.task.txt

Related: