Repository navigation
Trivial post-merge cleanup - #736
Conversation
|
Thanks, Gene. I agree with the principle: the Javadoc should say what the caller gets, not how. But most of what this PR removes is caller-visible behavior, not implementation:
The parts that really were implementation, I'm happy to drop: "since this debugger never becomes active, no breakpoint is checked" on I'd suggest: /**
* @return the debugger of this runtime's services: the one a host set, else none if the system
* property {@code org.xvm.runtime.debugger} is {@code off}, else the console debugger
*/
public Debugger getDebugger() {
/**
* Set the debugger of this runtime's services, in place of the default; a host without a
* terminal for the console debugger sets {@link Debugger#NONE}.
*
* @param debugger the debugger to use
*/
public void setDebugger(Debugger debugger) {Your shorter On the test: both cases together take 34 ms, and Gradle caches the result, so I don't think time is the issue. What it guards is the off switch you asked for in #718, and its precedence. That precedence changed during that review (from You're right that it isn't trivial, though, for two reasons you didn't mention:
How about keeping the coverage without either? Move the check out of the constructor: // in the constructor
m_debugger = initialDebugger(System.getProperty("org.xvm.runtime.debugger"));
/**
* @return the debugger a runtime starts with for the specified value of the system property
* {@code org.xvm.runtime.debugger}: none for {@code off}, otherwise null, so that the
* console debugger is chosen when it is first needed
*/
static Debugger initialDebugger(String setting) {
return "off".equals(setting) ? Debugger.NONE : null;
}and test just that, without a @Test
public void offTurnsTheDebuggerOff() {
assertSame(Debugger.NONE, Runtime.initialDebugger("off"));
assertNull(Runtime.initialDebugger(null));
assertNull(Runtime.initialDebugger("on"));
}That's trivial to understand and to run, and it fails if someone drops or renames the switch. If you agree, I can push it as a follow-up after this lands, or you can fold it in here. |
I still don't think it's a contract definition. For example, we may choose to change the property name. Or the change the runtime to switch it dynamically. Also, I'm thinking of a "log only debugger" that would print the frame info on "assert:debug". None of that is relevant to this API. As to the other suggestion - while it's very reasonable to design an implementation so it's "testable", in this case it's too trivial to spend any effort IMHO We shouldn't write tests for sake of writing tests. Not worth the entropy :-) |
a00aca7 to
ba8db74
Compare
This test is not entropy. Anything with an environment variable dependency CAN AND WILL break when you try to use it with a gradle build and have forgotten to declare dependencies and stuff. It takes 0.36 ms to run. |
|
Chad claims it's 38ms :-)
I asked it to reduce the test - please take a look if that satisfies you. According to Chad:
|
bf20612 to
aee47bb
Compare
aee47bb to
ddbcef9
Compare
|
@ggleyzer, thanks for reducing the test, and for merging. I still think we disagree on the Javadoc, though, and I'd like to make the case once more, because I believe it matters for the people who embed the runtime. A contract is what a caller can rely on, and here what a caller can rely on is the precedence: a debugger the host sets wins; otherwise On the test, the cost is settled: with your reduction it runs in about 1 ms. What it guards is the precedence we decided in #718's review, which already changed once during that review, and a system property is exactly the kind of input that breaks without anyone noticing, when it's renamed or not passed through a build. That's not a test for its own sake; it records a decision we made together. Two small things also slipped through: "Set the debugger of this runtime's services" is missing its period, and the field comment should read "null until it is set explicitly or lazily assigned". I'm happy to send a one-line follow-up with those, and with the caller-facing sentences for |
|
Sure; please do |
…typos #736 shortened the Javadoc of Runtime.getDebugger() and setDebugger(), and with it dropped what a caller can rely on: the precedence of a debugger the host sets, the org.xvm.runtime.debugger=off switch, and the console debugger, and that a host without a terminal sets Debugger.NONE. getDebugger() says the precedence again, as behavior and not as implementation; the switch was otherwise documented only inside the constructor. setDebugger() says only what a host without a terminal sets, since the precedence is getDebugger()'s to state. The field comment gets its missing "it", and setDebugger's first line its period. Validation: rebased onto master 22ec660; javatools compiles; javac -Xdoclint:all reports the same 12 warnings for Runtime.java as on master, and no errors; spotlessCheck passes.
I missed to rise a couple of points during the original review:
I believe there is no reason to put the explanation of the implementation into the Java doc; the doc describes the contract from the standpoint of the caller, and the implementation may vary over time
There is a price we pay for every test; it's time (to execute it) and entropy (to understand and maintain it). For a trivial test to exist, it needs to be both trivial to understand and trivial to execute. The RuntimeDebuggerTest test is starting the
Runtimeto test whether the system property worked. I think the ROI is too low