Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

baka kaba posted:

Cheers, I posted that in completely the wrong thread so uh thanks for the genuine reply! I've just been trying to get into the 'don't have tests relying on other tests' mentality, and this feels like it completely violates that idea.

The thing is, having a test that calls multiple methods isn't a test that relies on other tests. It's actually difficult to have a test that only calls one method, unless you're asserting that an exception is thrown or not thrown.

Also, this probably IS the better thread to post your question in, rather than the java thread.

Adbot
ADBOT LOVES YOU

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

baka kaba posted:

Cheers, I posted that in completely the wrong thread so uh thanks for the genuine reply! I've just been trying to get into the 'don't have tests relying on other tests' mentality, and this feels like it completely violates that idea. It seems mostly harmless when your methods are simple, but when they're not (or if they get more complex later) it could introduce problems where the cause isn't immediately obvious. That's what I'm worried about really. But yeah, wrong thread!

Yeah, it seems like something that's tripping you up is that "don't have tests that rely on other tests" in no way means "if one thing in the program is broken than only one test should fail." It's perfectly normal to have multiple tests fail when one piece of functionality is incorrect, since of course modules are going to depend on other modules in order to do their work properly. If storing a value is broken, then not only will the storing and retrieving test fail, but tests involving other modules that expect the value to be stored properly can also fail since they aren't getting values they expect.

hobbesmaster
Jan 28, 2008

Subjunctive posted:

I think *most* ordering you encounter in communication is unlabeled, because sequence of reading or hearing carries the ordering information. "Today we're going to 1) finish the code review, then 2) have lunch, then 3) write a witty post on SA" wouldn't be totally awkward, but is uncommon.


Yeah, I started with QtCreator, but it insisted on building 64-bit and wouldn't let me pick the 32-bit runtime once I forced it to find the 32-bit compiler and...yeah, I said a swear or two. I'll try again after a glass of wine later this week and see if I get there, because I'd really like to add this thing to the program!

You need a 32bit compiler, version of qt and debugger available to create a 32bit kit.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

hobbesmaster posted:

You need a 32bit compiler, version of qt and debugger available to create a 32bit kit.

Yeah, I have those things (msvc and msvc_64 or whatever directories, VC Studio can produce both outputs and I have both cdb flavours installed) but it for whatever reason refused to show up in the selection list.

I think I should probably start over, because it's clear I don't know what state I'm in at this point.

JawnV6
Jul 4, 2004

So hot ...

Subjunctive posted:

I think I should probably start over, because it's clear I don't know what state I'm in at this point.

Better yet, start over in C#.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Volmarias posted:

Also, this probably IS the better thread to post your question in, rather than the java thread.

:ohdear:

Yeah I see what you guys are saying - obviously I already have tests that involve multiple methods, even where I'm only explicitly calling one, so there's probably no actual difference here. I guess it's the extra layer of abstraction when setting up the test or asserting the results that's making me (unreasonably) suspicious about all this. A lurking horror, if you will

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

JawnV6 posted:

Better yet, start over in C#.

I really don't want to go down the rewrite hole, especially since it's under active development and I don't want to keep maintaining a fork, buuuuuuuuuut. Don't encourage me, jerk.

hobbesmaster
Jan 28, 2008

Subjunctive posted:

Yeah, I have those things (msvc and msvc_64 or whatever directories, VC Studio can produce both outputs and I have both cdb flavours installed) but it for whatever reason refused to show up in the selection list.

I think I should probably start over, because it's clear I don't know what state I'm in at this point.

Yes but do you have separate qt version entries for 32bit and 64bit? And do you have the 32bit and 64bit kits showing up?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

hobbesmaster posted:

Yes but do you have separate qt version entries for 32bit and 64bit? And do you have the 32bit and 64bit kits showing up?

The 32-bit kit wasn't showing up, no, though I selected it in the installer and it was in the directory and the components.xml or whatever. :iiam:

I'm sure I screwed something else up during the install, I'll try again later in this week when I have some spare time.

Slash
Apr 7, 2011

Subjunctive posted:

I thought it was choking on the "slots: " pieces in the C++ files, but as has become eminently clear I may in fact be the Qt PEBKAC hazard. Tool ergonomics are still lovely, though.

I've found that this can happen if you forget to include the Q_OBJECT() macro in your class header. Also your class must inherit from QObject if you want to use signals and slots.

hobbesmaster
Jan 28, 2008

Subjunctive posted:

The 32-bit kit wasn't showing up, no, though I selected it in the installer and it was in the directory and the components.xml or whatever. :iiam:

I'm sure I screwed something else up during the install, I'll try again later in this week when I have some spare time.

I always found it easier to compile it yourself. You need to have perl, ruby and python (2 only?) for qt5. Theres also a tool called jom that is basically a thin wrapper around nmake that adds support for multiple threads. You can download jom here: http://qt-project.org/wiki/jom

I'll quote from my local instructions, you'll only have to do this for 32bit if you already have 64bit working:

quote:

copy jom.exe into the qt folder
open a VS command prompt for the appropriate architecture

from there, in the qt source directory:
set PATH = C:\Perl\bin;C:\Ruby193\bin;C:\Python27\bin;%PATH%

configure -opengl desktop -nomake examples -opensource -prefix C:\Qt\Qt5.2.1\5.2.1\msvc2013_32_opengl
jom
jom install

You'll almost certainly have different versions of everything or want to use different paths, feel free. You can set your prefix to whatever folder you want, however paths will be screwed up if you move it from there afterwards so do it right the first time.

After this completes (should be less than an hour on a modernish computer) go into Qt creator, options, build and run, then Qt Versions. Manually add the path to qmake (C:\Qt\Qt5.2.1\5.2.1\msvc2013_32_opengl\bin\qmake.exe for my example). Go back to kits and add a kit using that version of Qt and the appropriate version of msvc. You should be good to create new build configurations with the new kits.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I reinstalled everything with only 32-bit stuff, and it seems to be working.

I'll keep that stuff in mind for a grim future in which I need it, though. Thanks!

Zorro KingOfEngland
May 7, 2008

Just found this in a very simple DB retrieval method

Java code:
return Lists.newArrayList(ImmutableSet.copyOf(resultList).asList());

Sedro
Dec 31, 2008
That's a pretty concise way to create a mutable copy of a list with duplicate items removed. Which doesn't make sense in the context of DB retrieval

Steve French
Sep 8, 2003

fritz posted:

He pushed the same broken branch and now it's broken again in exactly the same way, and I'm not gonna fix it this time.

Sounds to me an awful lot like your CI system is broken and maybe you should fix that.

fritz
Jul 26, 2003

Steve French posted:

Sounds to me an awful lot like your CI system is broken and maybe you should fix that.

It's jenkins, and it does a build on all commits pushed to a remote server that it tracks, the problem was that there was a build artifact that he removed from the index, but did not clean it up after the build, so:
* the bad branch would run
* it would leave the artifact around
* also the other changes in that commit meant the artifact was different than it used to be
* the next commit comes in, jenkins tries to 'git checkout'
* git won't overwrite the untracked file with the tracked one
* build fails
* repeat

I guess the horror could be that it doesn't scrub the directories clean before starting, but I don't think I have control of that part of the jenkins process.

I'm open for better practices here if y'all have suggestions.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Not building from a clean environment each time does in fact mean that your CI setup is broken.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Plorkyeran posted:

Not building from a clean environment each time does in fact mean that your CI setup is broken.

Uh, yeah this. If you're not cleaning the environment every time you're going to get everything from checkout failures to the compiler loving up and not recompiling files it previously compiled. Nuke everything all the time always.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only
If you want to avoid rebuilding things that haven't changed between revisions, then ccache is a better solution than keeping artifacts around in the source tree.

If you aren't always cleaning your source tree between builds, you have no proof that you can build from source.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Plorkyeran posted:

Not building from a clean environment each time does in fact mean that your CI setup is broken.

I've encountered the exception to this:

Continuous delivery builds with terrible structure leading to gigs of uncompiled content living alongside the application code.

The solution to that is, of course, to split the content from the code and have a separate, incremental deployment process for the content. Binary deployment doesn't touch content, content deployment doesn't touch binary.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

fritz posted:

I guess the horror could be that it doesn't scrub the directories clean before starting, but I don't think I have control of that part of the jenkins process.

https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin ?

Doctor w-rw-rw-
Jun 24, 2008

ultramiraculous posted:

Uh, yeah this. If you're not cleaning the environment every time you're going to get everything from checkout failures to the compiler loving up and not recompiling files it previously compiled. Nuke everything all the time always.
Or if you're working with git, and your checkout is too large to quickly re-checkout, then use git clean -f. This is the *simple* solution, but perhaps a better one would be to fetch commits into a bare repo, and always check out from that repo into a new working directory. The repo can be updated without much incident with new commits, and doesn't have to be re-cloned, but the folders where your project under test will live should definitely get nuked on each run.

Hughlander
May 11, 2005

Doctor w-rw-rw- posted:

Or if you're working with git, and your checkout is too large to quickly re-checkout, then use git clean -f. This is the *simple* solution, but perhaps a better one would be to fetch commits into a bare repo, and always check out from that repo into a new working directory. The repo can be updated without much incident with new commits, and doesn't have to be re-cloned, but the folders where your project under test will live should definitely get nuked on each run.

Yep, we have an aggressive script at work that keeps evolving as we find newer and better ways to gently caress things up. It does something like:

code:
git reset --hard && git checkout -- . && git clean -ffdx
git submodule sync && git remote prune origin && git submodule update --init --force
git submodule foreach 'git submodule sync && git remote prune origin' && git submodule update --init --force
git submodule foreach --recursive 'git clean -ffdx && git checkout -- .

Check if we're clean, if so exit:
git status --porcelain

No?  Extreme measures!
git submodule foreach --recursive `RUN THIS SAME COMMAND`
git submodule update --init --recursive

Nuclear option!
git status --porcelain | xargs rm -rf 

git status --porcelain
Still not clean?  Ok, I give up it failed.

revmoo
May 25, 2006

#basta
The fact that you needed to write that script is a coding horror. I've ran into similar issues with Git in the past. Seems like SVN is worse though.

hobbesmaster
Jan 28, 2008

revmoo posted:

The fact that you needed to write that script is a coding horror. I've ran into similar issues with Git in the past. Seems like SVN is worse though.

The "emulate clean checkout" option from the SVN plugin seems to work fine? I can't comment on jenkins+git.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Ithaqua posted:

I've encountered the exception to this:

Continuous delivery builds with terrible structure leading to gigs of uncompiled content living alongside the application code.

The solution to that is, of course, to split the content from the code and have a separate, incremental deployment process for the content. Binary deployment doesn't touch content, content deployment doesn't touch binary.
If I'm understanding the scenario you're describing correctly, my preferred approach there would be to keep the last built copy of each type of thing going into the full deployment around, and then redeploy everything but the thing being tested into a clean environment before building the thing being tested (or after building and before testing, as applicable). I'd consider that a "clean" environment, as while it won't be the same for every CI run, it isn't changing due to previous CI runs of the same component.

fritz
Jul 26, 2003

I guess I've been hoisted by my own petard here. Thanks for posts and info yall.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Does pulling into a local repo and then cloning in a new directory from there not make things clean enough? Do you have artifacts in the repository that make it infeasible?

dealmaster
Dec 24, 2005

Somebody call for an exterminator?
I found this gem in some Java code that was submitting infinite requests to a BPEL queue a while back:

code:
int i = 0;
while (i < someValue) {
    //do some things
    i = i++;
}
At first it looked odd, but I couldn't figure out what the issue was until I started thinking about the implications of using an assignment with a postincrement operator. Basically what happens is Java remembers what the value of i is, it increments it, then reassigns the old value. So i never increases in value. This threw me for a loop (no pun intended) when I first saw this. Don't do this if you want your loops to terminate. This code was live on a production server.

I also found some Java code that had a break statement in a finally block. This one really seemed dangerous and capable of causing all kinds of weirdness with execution flow. I decided to write a little method to test this out:

code:
public static void main(String[] args) {
    System.out.println(horrible());
}

public static int horrible() {
    for(;;) {
        try {
	    return 1;
	} finally {
	    break;
	}
    }
    return -1;
}
Guess what gets outputted here? -1 does. The code attempts to return 1, but is intercepted by the finally block, which then executes the break, and causes the return -1 to get executed. The developer that had written this was intentionally exploiting this execution flow "feature" to execute a bunch more code after the loop. He was conditionally executing a break in a finally block in order to circumvent normal execution flow. This code was live on a production server as well.

:psyduck:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

dealmaster posted:

I also found some Java code that had a break statement in a finally block. This one really seemed dangerous and capable of causing all kinds of weirdness with execution flow. I decided to write a little method to test this out:

code:
public static void main(String[] args) {
    System.out.println(horrible());
}

public static int horrible() {
    for(;;) {
        try {
	    return 1;
	} finally {
	    break;
	}
    }
    return -1;
}
Guess what gets outputted here? -1 does. The code attempts to return 1, but is intercepted by the finally block, which then executes the break, and causes the return -1 to get executed. The developer that had written this was intentionally exploiting this execution flow "feature" to execute a bunch more code after the loop. He was conditionally executing a break in a finally block in order to circumvent normal execution flow. This code was live on a production server as well.

:psyduck:

Trepanation sounds like a good solution for all parties.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

dealmaster posted:

I found this gem in some Java code that was submitting infinite requests to a BPEL queue a while back:

code:
int i = 0;
while (i < someValue) {
    //do some things
    i = i++;
}
At first it looked odd, but I couldn't figure out what the issue was until I started thinking about the implications of using an assignment with a postincrement operator. Basically what happens is Java remembers what the value of i is, it increments it, then reassigns the old value. So i never increases in value. This threw me for a loop (no pun intended) when I first saw this. Don't do this if you want your loops to terminate. This code was live on a production server.

i = i++ is undefined behaviour in C, so Java could have inherited that feature.

JawnV6
Jul 4, 2004

So hot ...

Edison was a dick posted:

i = i++ is undefined behaviour in C, so Java could have inherited that feature.

It didn't. I poked around a little after seeing that since sequence points come up in our interviews, and Java doesn't leave any ambiguity in these cases.

evensevenone
May 12, 2001
Glass is a solid.

Hughlander posted:

Yep, we have an aggressive script at work that keeps evolving as we find newer and better ways to gently caress things up. It does something like:

code:
git reset --hard && git checkout -- . && git clean -ffdx
git submodule sync && git remote prune origin && git submodule update --init --force
git submodule foreach 'git submodule sync && git remote prune origin' && git submodule update --init --force
git submodule foreach --recursive 'git clean -ffdx && git checkout -- .

Check if we're clean, if so exit:
git status --porcelain

No?  Extreme measures!
git submodule foreach --recursive `RUN THIS SAME COMMAND`
git submodule update --init --recursive

Nuclear option!
git status --porcelain | xargs rm -rf 

git status --porcelain
Still not clean?  Ok, I give up it failed.

This is why you just use a VM and start from the same image each time. Have one jenkins job that builds the image with all the build dependencies, and another that just spawns the VM from the image and checks your repo into a bare directory. Run the second one on every build, run the first one if you have to add new build dependencies. Copy your binaries off and trash the VM afterward.

That way you can give the image to the devs and mandate that their poo poo builds on the current image before they submit it for review. It also makes it pretty easy to parallelize your builds.

Jenkins is a creaky piece of poo poo, so it will take way too long to set this up, but it's totally worth it.

EAT THE EGGS RICOLA
May 29, 2008

Someone just handed me a ~7000 line javascript thing to look at and make major changes to by tomorrow at the latest. Every variable and method has a two or three character random name. For example something I might call getElementId is called sn.

I'm legitimately thinking of just pretending this conversation never happened and/or just killing myself so I don't have to deal with this.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

EAT THE EGGS RICOLA posted:

Someone just handed me a ~7000 line javascript thing to look at and make major changes to by tomorrow at the latest. Every variable and method has a two or three character random name. For example something I might call getElementId is called sn.

I'm legitimately thinking of just pretending this conversation never happened and/or just killing myself so I don't have to deal with this.

Did they give you a minimized version? That's actionable in civil court in many jurisdictions.

EAT THE EGGS RICOLA
May 29, 2008

Subjunctive posted:

Did they give you a minimized version? That's actionable in civil court in many jurisdictions.

No, this is how this was written in the first place.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

EAT THE EGGS RICOLA posted:

No, this is how this was written in the first place.

Do what you must. No jury in the land would convict.

fritz
Jul 26, 2003

I found a line in some academic C code just now that has 5 "="s, two arithmetic operators, and a [].

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

fritz posted:

I found a line in some academic C code just now that has 5 "="s, two arithmetic operators, and a [partridge in a pear tree].

Adbot
ADBOT LOVES YOU

Westie
May 30, 2013



Baboon Simulator

fritz posted:

I found a line in some academic C code just now that has 5 "="s, two arithmetic operators, and a [].

Please, share!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply