build: build the test objects through the rules - #7253
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change removes three Rake dependency rules for generated test artifacts in ChangesBuild dependency rules
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized build-rule change makes test objects rebuild when relevant headers or flags change, preventing stale test binaries while preserving compile behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`mrbtest.o`, `assert.o` and the `gem_test.o` of every gem were declared by hand in `mrbgems/mruby-test/mrbgem.rake`: action-less `file` tasks whose only prerequisite was the generated source. Rake does find the rule for such a task, but only when the task runs, after `needed?` was answered from that one file. The `.d` the compile writes and the flags record are read by the prerequisite procs of the rule, and for these objects they never ran. A header the object includes changing, or a define reaching the build without a new source, left the old object in `mrbtest`. `mrbtest.c` reads `mrb->gc.arena_idx` around every gem's tests. Add a field to `struct mrb_state` and run `rake test`: every other object is compiled again, `mrbtest.o` is not, and `mrbtest` prints one dot and exits with 1. A second `rake test` changes nothing. Drop the three tasks so the objects are built the way `mrblib.o` and `gem_init.o` are: by the rule of the compiler that pairs an object under the build directory with the source beside it and reads its `.d`. The compile lines do not change; the objects were compiled by that rule before too, only without its prerequisites.
8768443 to
8550a40
Compare
mrbtest.o,assert.oand thegem_test.oof every gem, the objectsmrbtestis made of, are declared by hand inmrbgems/mruby-test/mrbgem.rake:filetasks without an action, with thegenerated source as their only prerequisite. Rake finds the rule for such
a task, but only when the task runs, after it has already answered
needed?from that one file. The.dthe compile writes and the flagsrecord beside the object are read by the prerequisite procs of the rule,
and for these objects those never ran. A header the object includes
changing, or a define reaching the build by a way that leaves the
generated source alone, left the old object in
mrbtest. It is the samegap #7250 closed for
mrbgems/gem_init.o.mrbtest.creadsmrb->gc.arena_idxaround every gem's tests(
mrb_gc_arena_save,mrb_gc_arena_restore). Add a field at the top ofstruct mrb_stateand runrake test:Every other object of the build is compiled again;
mrbtest.okeeps theold offset of
gc.arena_idx, andmrbtestexits after the first test.Why
The three tasks came with the test rakefiles (2014, 7201404; 2015,
c7d0f8e). Rake's
Task#executerunsenhance_with_matching_rulefor atask without an action, so the rule's action does compile the object and
its prerequisite procs do run then; but that is after
invokedecidedfrom the written prerequisite whether to execute at all. The rule from
Compiler#define_ruleshas paired an object under the build directorywith the generated source beside it since 2013 (ced80d2);
mrblib.ois built by it alone, and
mrbgems/gem_init.osince #7250. It reads the.dand discards an output whose recorded flags differ (#7236).What this does
mrbgems/mruby-test/mrbgem.rakeno longer declares the three kinds ofobject. The rule of the compiler pairs each with its generated source,
and its
.dand flags record take effect. The compile lines do notchange: the flags record of every one of the 271 objects of a
rake testbuild is the same as on
master.Verified
rake -m -j16 test,CCACHE_DISABLE=1, gcc;defaultgembox withenable_bintestandenable_test; the build directory built once onmaster(364d6dd) before each row, and the run after each row doesnothing in both columns.
struct mrb_stateininclude/mruby.hCC, none of the 52 test objects among them;mrbtestprints one dot and exits with 1, and still does after anotherrake testCC, 51 test objects among them (assert.oincludes no header); bintest OK 111, mrbtest OK 2073CC, 51 test objects; bintest OK 111, mrbtest OK 2073touch include/mruby.hCC, none of the test objectsCC, 51 test objectsrake -m -j16 testfrom an empty build directorymasterrake -m -j16 test MRUBY_CONFIG=ci/gcc-clangfrom an empty build directoryEnvironment
Details
The compile line of
mrbtest.oin the default build, unchanged by thisPR (the record beside the object):
gcc -MMD -c -std=gnu99 -g -O3 -Wall -Wundef -Werror-implicit-function-declaration -Wwrite-strings -DMRBTEST_COMPILER_PRISM -DMRBGEM_MRUBY_TEST_VERSION=0.0.0 -DHAVE_MRUBY_REGEXP_GEM -DMRB_USE_SET -DHAVE_MRUBY_IO_GEM -DMRB_USE_RATIONAL -DMRB_USE_COMPLEX -DMRB_USE_BIGINT -DMRB_USE_DEBUG_HOOK -I"include" -I"build/host/include" -o "build/host/mrbgems/mruby-test/mrbtest.o" "build/host/mrbgems/mruby-test/mrbtest.c"No C source changes and the compile lines are the same, so
.textisunaffected in every build.
Summary by CodeRabbit