Are their semi automatic tools to help produce min

2019-07-11 03:21发布

An example: you have a large complex webpage which is broken in some little way, say a button isn't clickable when it should be, and used to be. You can use git bisect to find out when it broke, but I'm curious about tools to help you find why it broke. Image it broke after a large commit, or perhaps you only have a webpage with no version history.

Typically to debug something like this you go through the following process to reduce the big complex page into a minimal test case:

Step 1: remove something randomly from the code which results in:

a) the bug is still there, but the code is now smaller than it was b) the bug is NOT there, and the code is now smaller than it was c) the bug is ambiguous, ie it's important to the feature/bug and can't be removed so put it back

Step 2: rinse and repeat until the code changes become smaller and smaller until nothing else can be removed and you have your minimal test case.

Whatever is randomly removing stuff would need to at least superficially aware of the domain, eg only remove a full css selector, or only remove pairs of matching html tags, or else almost all modifications would ambiguous and rolled back, so it would be impractical.

So do any tools like this exists, in any problem domain? I'd imagine something like:

 > reduce file.html
 Removed 10 html elements, does it (w)ork, (n)ot work or (c)an't tell?: w
 Removed 4 html elements, does it (w)ork, (n)ot work or (c)an't tell?: c
 Removed 5 css rules, does it (w)ork, (n)ot work or (c)an't tell?: n
 Removed 3 html elements, does it (w)ork, (n)ot work or (c)an't tell?: w
 Removed 2 html attributes, does it (w)ork, (n)ot work or (c)an't tell?: c
 Removed 2 css declaration, does it (w)ork, (n)ot work or (c)an't tell?: a
 Removed 1 html element, does it (w)ork, (n)ot work or (c)an't tell?: n
 Removed 1 text node, does it (w)ork, (n)ot work or (c)an't tell?: n
 Can't reduce anymore, reduced case is found: file.html.reduced

The process could tune the level of reduction in each step, so if it is getting a lot of (c)'s it could try making smaller changes each time, and if it is constantly still working or not working it could ramp up into bigger more brutal reductions.

And instead of being a prompt you could pass it some automatic way to testing which of the 3 conditions it is in.

So does anything like this exist in any problem domain? Are there any generic frameworks for building something like that which you could plug new types of files/domains into?

0条回答
登录 后发表回答