Problem:
When I run the same go test twice the second run is not done at all. The results are the cached ones from the first run.
PASS
ok tester/apitests (cached)
Links
I already checked https://golang.org/cmd/go/#hdr-Testing_flags but there is no cli flag for that purpose.
Question:
Is there a possibility to force go test to always run test and not to cache test results.
There are a few options as described in the testing flags docs:
go clean -testcache: expires all test results
use non-cacheable flags on your test run. The idiomatic way is to use -count=1
That said, changes in your code or test code will invalidate the cached test results (there's extended logic when using local files or environment variables as well), so you should not need to invalidate the test cache manually.
In Go11, I couldn't disable cache using GOCACHE with modules, I used -count=1 instead:
go test -count=1
Prior to Go11:
GOCACHE=off go test
Or, clean test cache and run test again:
go clean -testcache && go test
There's also GOCACHE=off mentioned here.
The way that I fixed this (I'm using Visual Studio Code on macOS):
Code > Preferences > Settings
Click ... on the right hand side of the settings page
Click Open settings.json
Either:
Add the following snippet to your settings.json file
"go.testEnvVars": {
"GOCACHE": "off"
}
Change the value of go.testEnvVars to include the following: "GOCACHE": "off"
For VS Code (in 2022)
Open VSCode's settings.json. To open settings.json, press Ctrl + , (or Cmd+, on Mac), then click the Open JSON button shown below. Optionally, if you don't want to set this globally, you can create a .vscode/settings.json file at the project root.
Set the go.testFlags value in settings.json:
{
"go.testFlags": ["-count=1"]
}
Save and enjoy.
Note: these steps ensure test cache will be skipped every time. If you want a one-time fix, then run go clean -testcache in the terminal, as Marc's most-voted answer says.
Related
I have direnv installed, and I was wondering if there was a way of stopping it from showing all of the environment variables it loads? The output lines it currently shows are:
direnv: loading .envrc
direnv: export +FOO +BAR +FOO2 +BAR2 +FOO3 +BAR3 +FOO4 +BAR4
I'm fine with having the first line show, but since my second line has something like 50 variables in it, it's slightly annoying to have the lot of them shown every time I go into the directory.
It's possible to remove the logs entirely by setting export DIRENV_LOG_FORMAT= but then the rest of the logs are also missing
As far as I know, you cannot change that behavior through configuration.
If that behavior was part of the stdlib, you could override it. In fact, the first ouput, direnv: loading .envrc comes from source_env which uses log_status to output to stderr, so you could override either of source_env or log_status in ~/.config/direnv/.direnvrc or ~/.direnvrc.
However, the second output is coming from diffString in cmd_export.go (via log_status in log.go). Short of compiling your own, modified version of direnv, I don't see how you can change that behavior as of the current release (v2.17.0).
I've got the following code in a thread in my application:
while (true) {
if (ready) {
progressIndicatorController.value++;
return;
}
}
The ready variable is changed from a delegate method. This code works great when I open the application by clicking the "Run" button in Xcode's toolbar. However, if I open this application's .app (which I create by clicking Product > Archive and then following the steps) this code somehow doesn't work anymore.
progressIndicatorController.value is never incremented and this if-statement never evaluates to true. What could cause this problem?
This is probably caused by optimization from the compiler.
When you build with Archive, XCode enabled optimization in the compiler that could throw this kind of code away. I think setting the ready variable to volatile could fix your problem, altough if I were you I'd just try to rewrite it so it doesn't trigger this problem.
You can test with optimization turned on by choosing Edit Schemes in the scheme dropdown. Then set Build Configuration to Release in the Run MyApp.app. Don't forget to set it back to Debug when you're done though, as the debugger gets somewhat confused when optimization are on (i.e. you can't see the value of most variables, some breakpoints may behave erratically, etc...)
In my app I have an option defined in the Settings.bundle that is used only for debugging purposes.
Is there a way of hiding this from code, for when the application is in production, without manually deleting the option from Settings.bundle/Root.plist ?
Something in the lines of:
#ifdef DEBUG
// Remove the option from the settings bundle
#else
// Show the option in (or don't actually remove the option from) the settings bundle
#endif
Thank you!
There're a few options:
use a separate dev target with special Settings.bundle,
modify Settings.bundle with a Run script at Build Phases for the single target adding the section for DEBUG configuration, check CONFIGURATION variable for that.
I'm almost certain there is no way to do that.
This is a bit of a newbie question, but... is there a way to make actions optional in Selenium IDE? I'll provide a use case.
In the app I'm testing, users see a "hey, you're agreeing to the ToS by logging on"-type modal window at the beginning of each session. They have to click OK to continue, and they don't see the window again until the next session.
Based on what I've seen so far, I need to have one test suite for the first test each day, and a second test suite for all the others. The second suite is exactly the same except that it doesn't have the "click okay to dismiss the initial modal window" step. Alternatively, I could just remember that my first run of the test each day will fail, and that I have to run the test again.
Both of those "solutions" seem unnecessarily awkward. Can I just make the click command optional?
Create a javascript file called user-extensions.js with the below code. Then go into the Selenium IDE Options dialog and select your user-extensions.js file, restart Selenium and you'll be able to choose TryClick which will work the same as Click but suppress any errors.
Selenium.prototype.doTryClick = function(locator) {
try {
return Selenium.prototype.doClick.call(this,locator);
} catch(err) { return null; }
};
Perhaps overdue, but for future searchers.
You could use the if and endIf statements within the IDE.
If you are using cookies to decide whether to hide the ToS dialog, you could check that a certain cookie is set and if so, skip the click.
I haven't used the selenium IDE much, but I think doing the check would be much easier if you are using a programming language. I am not sure how to do it in HTML tests.
If you are using HTML, you could have a look for Selenium IDE Flow Control and see if that can do what you need. I haven't used this myself, but if looks like it supports if statements. You could use verifyCookie to check if the cookie exists.
Hope that helps.
As aj.esler pointed it out Selenium ID Flow control is a good solution that has worked for me.
Here is the Firefox add on
I use the gotoif, here is an example about how you can use it. When skip value is 1 then it will go to the label=jump line and will not execute everything from gotoif like to label=jump .
Another extremely useful flow control add-on for the IDE is SelBlocks
It will give you the ability to use: if/else/for/foreach/while and even a way to read variables from an XML file.
Use http://wiki.openqa.org/display/SEL/flowControl addon.
Make something like this :
1.storeElementPresent | //button[#name="cookie_law_accept"] | cookie_law
2.goToIf | storedVars['cookie_law']!=true | end
3.click | //button[#name="cookie_law_accept"]
4.label | end
Explain:
1.If element is present it will be stored as a "cookie_law" with value "true"
2.If cookie_law is not "true" - go to label "end" - other way go to next step
3.Click to cookie accept button (only when itsenter code herepresent because it its not - you go to "end" label and you skip this command)
4.You go here if there is no cookie law button :)
I'm working on a script to interact with Perforce, which among other things needs to be able to understand pending changelists. For this I use 'p4 describe' and 'p4 opened', which are pretty straightforward. For instance, a file opened for edit shows up like this (from p4 opened):
//source/stuff/things.h#1 add default change (text)
What I can't seem to figure out is how to detect cases where a user has branched a file and then used the 'Reopen for edit' command on that file (which amounts to using 'p4 edit' on the file to be branched) prior to submitting it. Same thing goes for integrating a file and then using 'Reopen for edit' before submitting the integration. In the branch case, the file shows up as an 'add' with no indication that there's also a branch going on (so the above example could be either a true add or a reopened branch). In the integrate case it, shows up as an 'edit'. In both cases, after I submit the change I can see that the file was branched/integrated, but I need to be able to do this for pending changes. In theory I would hope to see something like this, where things.h is being branched and edited from thangs.h:
//source/stuff/things.h#1 add default change (text)
branch from //source/other/thangs.h#42
Does anybody know of a way to accomplish this? I'll also mention that I'm running an old-ish version of Perforce (from 2004), so perhaps it's doable in newer versions and I just need to update my software.
"p4 resolved" does almost exactly what you want, but unfortunately it is new in 2007.2.
[C:\dfp\Common\Code\Python]p4 opened foo.py
//buddha/Common/Code/Python/foo.py#1 - add default change (kxtext)
[C:\dfp\Common\Code\Python]p4 resolved foo.py
c:\dfp\Common\Code\Python\foo.py - branch from //buddha/Common/Code/Python/memdump.py#1,#30
You probably won't be able to detect problems before the user runs "resolve", but they're going to have to resolve before they submit.
I do not think that this is possible when issuing a "reopen for edit". As you have already indicated, the reopen command will change a files status to something different. I ran a local test (I'm running 2008.2). There do seem to be some changes in the way that perforce reports on the add/edit status of files since your version, but what you are trying to do still doesn't seem possible
d:\sandbox\ctg_test>p4 integ test.txt test_branch.txt
//ctg_test/test_branch.txt#1 - branch/sync from //ctg_test/Test.txt#1,#15
d:\sandbox\ctg_test>p4 opened
//ctg_test/test_branch.txt#1 - branch default change (text)
Note that the opened command now shows 'branch' for the file status instead of add which I think it might have shown with your version of the server. But the kicker:
d:\sandbox\ctg_test>p4 edit test_branch.txt
//ctg_test/test_branch.txt#1 - reopened for add
d:\sandbox\ctg_test>p4 opened
//ctg_test/test_branch.txt#1 - add default change (text)
I tried looking with the -ztag option to see if more info was given:
d:\sandbox\ctg_test>p4 -ztag opened
... depotFile //ctg_test/test_branch.txt
... clientFile //client-mark.allender/ctg_test/test_branch.txt
... rev 1
... action add
... change default
... type text
... user mark.allender
... client client-mark.allender
p4 fstat was no help either.