We take complex science and translate it into practical solutions to help you feel Uplifted!
At Uplift Food HQ our focus is on helping you, our fellow Uplifter, easily get more beneficial PRE-biotics into your body.
This includes having the mental and physical strength to take on the challenges that are thrown at us, whatever they may be.
Uplift Food aims to be the go-to global provider for trustworthy and innovative PRE-biotic products connected to mood.
We are here to start a global movement of Uplifters who together will passionately spread the message of the importance of including prebiotic gut healthy foods in order to feel Uplifted in life!
To make quality mood supportive gut healthy prebiotic foods and information accessible, understandable, and incorporated daily, by all.
Being your trusted go-to resource on everything related to PRE-biotic gut healthy foods and the connection between gut health and mood.
Acting with integrity and not confusing you with misleading marketing. We will instil knowledge and confidence in you so that you can make up your own mind on our products, of which we truly believe in.
Actively listening to you, and offering you the solutions you need to feel confident in implementing your prebiotic gut healthy lifestyle.
Continually researching and innovating on our product offerings so that they reflect up to date science.


text:
Speaking of Miracles
By Guy Yocom
Nicklaus shot 30 on the final nine despite a bogey at the 12th, taking the lead with this birdie at the 17th.
When the leaders churn into Amen Corner this Masters Sunday, there is always the chance the ensuing hours will leave us limp and exhausted in our easy chairs, the nerves shot. There even exists the possibility that the back nine will produce a drama that surpasses all others. At the Masters, you never know.
The problem with that fantasy is the 1986 tournament, which so far has left other contenders for "most memorable Masters" fighting for second place. On a warm, windless Sunday two decades ago, Jack Nicklaus charged to a record sixth Masters in the most brilliant closing performance of his career. For two riveting hours, the sum of Nicklaus' genius poured forth without subtlety or letup in an all-at-once display of the qualities that made him the best golfer of all time.
The 1986 Masters was already one worth remembering, but then Nicklaus waded into a sea of Hall of Fame contenders and got the best of them all.
Twenty years later, the images and sensations of that day are so fresh that some of the people involved come out of their chairs as they describe them. Others struggle to find the words, as though the events still haven't sunk in.
Nicklaus arrived at Augusta that week in a deep slump, having missed the cut in three of seven tournaments that year. He had withdrawn from a fourth. He stood 160th on the PGA Tour money list. He hadn't won a tournament in two years, and his last major was six years distant. At age 46 and with 19 major championships, he seemed just another long-shot contender.
We begin the story with the Nicklaus family arriving at Augusta.
Marilyn Hutchinson, Jack's sister: For years the Masters was mainly a trip for the guys. Our family had gone down to Augusta in 1959 -- Jack's first Masters -- in a car without air conditioning. The house we stayed in didn't have air conditioning, either.
We sang much of the way, songs like "Blue Skies," "Tennessee Waltz" and "I Married an Angel." We made a lot of car trips when we were young, and that's how we'd pass the time.
Dad and Jack's friends Pandel Savic and John Montgomery were regulars, and sometimes there were others. When Dad passed away in 1970, we girls still weren't inclined to go. But by 1986 Mom was feeling her mortality. She'd had a heart bypass, which was a bigger deal then. One day in 1985 she said, "I'd like to go to the Masters one more time." So we all went.
__Barbara Nicklaus, Jack's wife:__There were too many of us to fit in one house, so we gathered at the main house for dinner. The house had a piano, and after dinner we sang. Did Marilyn tell you we love to sing? I played songs I knew, but also off some sheet music the owners had. There were a lot of church hymns. Jack's mother liked singing those songs. She knew all the words.
John Montgomery, family friend: In 1986, my son was over in Atlanta and read an article by Tom McCollister [of The Atlanta Journal-Constitution] saying Jack was washed up. I arranged to have it sent over, and when it landed I put it on the door of the refrigerator. Jack is a refrigerator freak -- he's there constantly out of habit, looking more than eating. When he saw the story he said, "I don't need to guess who put this here."
See, I'd always played practical jokes on Jack. I had several tons of horse manure dumped in his front yard once, another time filled it full of chickens. That article, he had to see it at least 20 times that week. I don't know to what degree it motivated him, but he never took it down.
McCollister, who died in an automobile accident in 1999, shared his memories years after Nicklaus' victory: "Like a lot of people, I decided to do a chart and put a comment on each one of them, what their chances were. I got to Jack, and I just thought he hadn't played well all that year, or the year before. So I just wrote that he's done. It was just a big paragraph, really."
Jack Nicklaus: You know, I can't remember much about that article. These days my memory is very good about things I think were important, and not very good about incidental things. I mean, reading an article isn't going to help you hit the shots.
Nicklaus' indifferent play was not the chief subject of talk about him early that week. Rumors also swirled that his businesses were in trouble and that he was in deep financial difficulty.
__Rick Reilly, Sports Illustrated:__We got a tip that Jack's businesses were a mess and that he was broke, so my first job that week was to ask Jack about that. I was 28, already had an ulcer, and now this. I saw Jack in the clubhouse on Wednesday and very nervously asked him if the rumors were true. He said, "Come on, let's go up to the Champions Locker Room and talk." And he gave me an hour. He was fantastic. It turned out he was only overextended.
__Jack Nicklaus:__Some things had happened in business that had put me in a horrible financial mess. Cost me a lot of money. But that's part of life; it happens. It was a distraction, but not to the extent some people imagined it was.
By 1986 I was not the player I was 15 years earlier. And I've always felt the Masters was a young man's tournament because of the speed of the greens, the firmness of the course and the demands it puts on your nerves. There are so many fine little shots you have to play there. If your game isn't right going into Augusta, it sure as heck isn't the place to find it. Still, there wasn't much rough, so I didn't need the strength to get the ball out of there. I might have been 46, but my nerves were still good. And I did not want to leave the game playing poorly.
The 1986 Masters began routinely. On Wednesday, Gary Koch won the Par-3 Contest, in which Gary Player made a hole-in-one. Arnold Palmer, 56, pronounced he was there to win. On Thursday, the first-round lead was shared by Bill Kratzert and the iconoclastic Ken Green, whose sister Shelley was on the bag to see her brother hole putts from everywhere for a 68.
__Ken Green:__That was my first round of my first Masters, and though they don't keep these kind of records, I'd bet it was the greatest putting round in the history of the tournament. I made putts of 35, 40, 50 and 70 feet, and a bunch of 10- and 15-footers for par. I was playing terribly but kept making these monster bombs. The next day I hit the ball about the same, but nothing fell. I holed a bunker shot to shoot 78 and make the cut with not a lot of room to spare. Can you imagine having the first-round lead and then missing the cut?
Nicklaus also had a family member caddieing for him, his 24-year-old son Jackie, the reigning North and South Amateur champion.
Jack Nicklaus II: I'd caddied for my dad many times before. The first time was at the 1976 British Open at Birkdale, when Dad's regular caddie tore an Achilles' tendon during a practice round. I stepped in and picked up his bag, and he hit an approach shot to the green. I started following, and he stopped me. "If you're going to caddie, you have to do the whole thing."
I'd forgotten to replace his divot. What did I know? I was 14 years old. Dad tied for second that year. I caddied for him quite a few times after that.
Jack Nicklaus: I like someone on the bag I can talk to. Jackie was a good player, and he also knew my game. Most of all, he knew me. He knew what to say and when to say it. He gave me a good opinion on the greens and other things, but it was just an opinion. I've always made my own decisions on the golf course.
__Jack Nicklaus II:__The one downside to caddieing at Augusta is the white caddie uniforms. They made me feel like a Good Humor Man. They looked funny, they were hot, and the pollen from the trees would cling to them. I had allergies, and when I'd bring my arm up to scratch my nose or to cough, the uniforms made it worse.
One thing I remember is the fried pork-chop sandwiches they served in the caddie area. The meat was served up, bone included, on fresh Wonder Bread with a squirt of mustard, and the bread soaked up the grease. I had the idea they weren't very healthy, but they were too good to resist. I ate a couple after every round.
Nicklaus opened with a 74, a typical score for him that year. The round was not inconsequential to a 21-year-old who the year previous had won the Western Open as an amateur, then drew Nicklaus as a playing partner at Augusta.
Scott Verplank: I had to be dying, because I don't remember a damn shot I hit. But 20 years later, I still remember every shot he hit. The back nine was flawless. There still was nobody who could hit it like he could. Walking up to the clubhouse after we'd signed our cards, I said to Jackie, "If your Dad keeps his head still on the putts, he could still win."
I didn't make the cut, and on Sunday I was back in Stillwater and was sitting in front of the TV, having goose bumps just like everyone else.
Nicklaus followed with a 71, and after 36 holes he was six strokes behind the leader, Seve Ballesteros. Although Nicklaus was in a tie for 17th place, his play had a propitious quality.
Jack Nicklaus: They were the best two rounds I'd played all year. All season I had hit the ball poorly but putted very well. When I got to Augusta, it flip-flopped. On Thursday I had 11 putts inside 15 feet and made one. On Friday I had it inside 15 feet 12 times and made four. I knew that if I could make a putt, I could scare somebody -- probably me.
__Jack Nicklaus II:__The neat thing was, he didn't seem to get frustrated. He'd been around long enough to know he was close, and to be patient. Boy, was he patient. As for his ball striking, Dad was hitting the ball great, but I'd never seen him play poorly. It's still true today. In my life, I've seen him hit maybe four drives low and left.
The putter Nicklaus used turned heads. The MacGregor Response ZT, a radically oversize model similar in design to a Ping Anser, was far different from the heel-shafted putters Nicklaus used for most of his career.
__Jack Nicklaus:__That putter took some getting used to. During the tournament at Eagle Trace before the Masters, I practically whiffed a putt with it. It was an eight-inch putt, and I hit it fat -- the putter bounced up and hit the ball all of two inches. But as the year went on I started rolling the ball nicely. That putter had been on the market awhile, but going into the '86 Masters we couldn't give it away. After that Masters, I believe we sold 350,000 of them.
You know, there are only two important clubs from my major-championship wins that went missing. One of them was White Fang [the Bulls Eye putter painted white and used to win the 1967 U.S. Open at Baltusrol]. Three years ago, when my son Steve turned 40, his roommate from college came down and said, "Steve, you gave me this club years ago, and I was wondering if it had any significance to you." It was White Fang, and I was glad to have it back.
The other club that got lost is my putter from the 1986 Masters. Most likely one of my kids gave it away. Somebody, somewhere has it.
On Saturday, Nicklaus shot 69 to climb into a tie for ninth, four strokes behind Greg Norman. The big news, however, was made by a 29-year-old breaking the course record.
Nick Price: After 14 holes I was seven under, and I asked my caddie if he knew what the course record was. I knew; I just wondered if he knew. And when he told me he knew -- he was too superstitious to come right out and say it was 64 -- I said, "Let's try to break it." I birdied 15 and 16 to go nine under. Then I burned the edge on 17. On 18 my putt for a 62 was a full horseshoe lipout, came right back at me.
You know, one of these kids who drives it 380 is going to break it. Somebody like Bubba Watson is going to have a good day on the greens, and that guy's going to shoot 62. It's just a matter of time.
*The leader board after three rounds:
Greg Norman: -6
Seve Ballesteros: -5
Bernhard Langer: -5
Donnie Hammond: -5
Nick Price: -5
Tommy Nakajima: -4
Tom Kite: -4
Tom Watson: -4*
On Sunday, Nicklaus was in the fifth-to-last group. Ahead of him were players who would combine for 21 major championships. Before heading to the course, Nicklaus got a call.
Jack Nicklaus: When I talked to Steve that morning he said, "What do you think, Pops?" I told him I thought 66 would tie and 65 would win. Steve said, "That's the number I had in mind."
I was only four strokes behind. There were eight very good players ahead of me, but I didn't feel it was likely that one of the guys in front would shoot a real low number and run away. Also, it was unlikely any of the guys behind me would shoot a super-low score, a 63 or something, and come from way behind. I just felt 65 was the number that would get the job done. As it turned out, it was exactly the number I needed.
Nicklaus was paired with Sandy Lyle, the defending British Open champion, who would win the Masters two years later.
Sandy Lyle: It started off as quite an average day, no sense of high expectations.Winning seemed out of the picture.
I remember he went into the trees at the second, and again at the eighth. On 8, he must have been 25 yards into the trees on the right. But he hit what looked like a 3-wood through 50 yards of trees and up short of the green. The crowd went nuts. Anyway, he came out of there with a huge grin. I asked him why he was so happy.
Jack Nicklaus: I got a terrific break on No. 8. I pushed the shot badly. Not only did it not go left of the trees, it went to the right of them, where there were more trees. But the ball found a little gap and hit nothing but air. I made par there, and it very easily could have been a 6. That hole turned it around for me.
Jack Nicklaus II: On Sunday he missed a couple of putts on the front nine. Dad's tendency in putting was to peek, to lift his head. Early in the week he told me to remind him to keep his head still. I did that, on every single putt. A few times he peeked anyway, and when he did I told him. Needless to say, there was no peeking on the back nine on Sunday.
A dozen players were ahead of Nicklaus as he approached an 11-foot birdie putt on No. 9. But he backed off twice, first after Kite holed a wedge from 100 yards on No. 8 for an eagle, and then again after Kite's playing partner, Ballesteros, followed by holing from 60 yards for an eagle of his own. Nicklaus was six shots behind before making the putt for his first birdie of the day.
__Marilyn Hutchinson:__After the putt went in at 9, Uncle Frank looked at the leader board and said, "This is not looking good" and decided to leave. We were right by the clubhouse, and I guess it looked convenient. So he and Aunt Rachel said goodbye and left. But they weren't the only ones who left early.
Nicklaus birdied the 10th with a 25-foot putt, and the 11th from 20 feet. After a bogey by Ballesteros at the ninth, Nicklaus suddenly was two shots off the lead. He strode to the 12th tee, where he received a huge ovation.
__Jack Nicklaus:__After I birdied 9, 10 and 11, I got nervous. I realized I was on a run. I backed off on my shot at No. 12 and didn't go for that pin, which always is on the right. Instead I pulled a 7-iron and wound up on the back fringe on the left.
My chip took a bad kick to the left, which left me with six feet for par. There was a spike mark right in front of my ball, a big one. I hit a good putt, but the spike mark made it veer just to the right. That made me mad. The hole in general made me mad.
__John Montgomery:__After Jack bogeyed the 12th hole, Pandel and Janice Savic left for the airport. Since that day, we've never let Pandel forget that he abandoned Jack in his desperate hour. I tease him unmercifully about it, and I can tell it bothers him.
__Jack Nicklaus:__When I got over my tee shot on 13, I figured if I was to have any chance at all, I've got to kick myself in the rear, get aggressive and just go.
Jack Nicklaus II: If a ball catches one of the branches on the left at 13, it's going in the water. It almost always does. He used a 3-wood and pulled it a little. It missed one branch by a foot. I told him, "Dad, that's not good on a 24-year-old's heart."
__Sandy Lyle:__Jack came back with, "What about me? I'm 46!" His son was much more nervous than he was. Jack never stopped chatting. He moaned after hitting those drives into the trees on the front nine, but there was no cursing. I thought it was remarkable that his manner never changed from start to finish.
__Jack Nicklaus:__I was so close to Rae's Creek that an overhanging branch could have interfered with my second shot if I hit it high, like you're supposed to. I had to go low with a 3-iron, and I put it on the green and made birdie.
Ken Venturi, 13th-hole announcer, CBS Sports: On Friday, I had made a remark that Jack needed to start considering when it was time to retire. He wasn't playing like Jack Nicklaus. But when he moved into contention, his body and mind went back in time. You could see it. When I saw him at 13, he was a different man.
Meanwhile, the leaders had made the turn. Norman, struggling to keep his game together, double-bogeyed the 10th hole for the second time that week. Ballesteros parred the 10th, Kite birdied the 11th, and both players parred the 12th. The leader board, frenetic and changing every minute, looked like this:
*Seve Ballesteros: -7 through 12
Tom Kite: -6 through 12
Jay Haas: -5 through 18
Payne Stewart: -5 through 16
Jack Nicklaus: -5 through 13
Greg Norman: -5 through 10*
As Nicklaus was making a par at No. 14, Ballesteros played a gorgeous 6-iron second to No. 13 and made an eight-foot putt for his second eagle of the day to move to nine under. Kite made a routine birdie, and Norman followed his double bogey with pars at the 11th and 12th. Ballesteros now had a two-stroke lead over Kite and a four-stroke lead over Nicklaus and Norman. Ballesteros appeared a lock to win his third green jacket. He doffed his visor and shook hands with his caddie, his older brother, Vicente. That's when hell began to break loose at Augusta.
__Frank Chirkinian, coordinating producer, CBS Sports:__There were players contending all over the golf course, and my job was to stay a step ahead of everything, anticipating where to go next. It's very clinical. You're so busy you don't have time to get caught up in the emotion or excitement. If I were to ever look at the line monitor -- the picture we're giving the viewers -- I would become a viewer myself, and that's fatal.
I knew I couldn't stay fixed on one scene for very long. Fortunately for me there was the miracle of videotape; if one shot overlapped another we simply went back and replayed it, giving it a live flavor but announcing of course that this was "moments ago, on tape."
__Jack Nicklaus:__My tee shot at 15 was a very good one. I had over 200 yards to the green, and I said to Jackie, "How far do you think a 3 will go here? And I don't mean a 3-iron." Jackie said, "Let's see it."
I loved the way that shot set up, because I could go right at the pin. At Augusta you always have to protect one side of the hole -- there's danger if you miss it to the left or right, depending on where the hole is. On 15 that day I had a lot of confidence standing over the ball. I chose a 4-iron and hit the ball solid, very high, the ball stopping just a shade past and to the left of the hole, 12 feet away.
When the putt went in, I saw Jackie jump out of the corner of my eye. I mean, for Jackie, he really got up there. So on the way to the next tee I said, "If you jumped like that all the time, you could've played basketball at North Carolina instead of golf."
__Jack Nicklaus II:__I was so excited but tried to rein it in. I caddied for Dad in the 1982 U.S. Open at Pebble Beach. In the final round he birdied 3, 4, 5, 6 and 7 to share the lead. I was beside myself, and on the eighth hole I said, "Dad, this is great! Keep it going!" He promptly bogeyed the hole. I didn't want a repeat of that.
I was very careful not to distract him. I'd say matter-of-factly, "Nice birdie. Let's make another one." By then I knew enough to try to help him to stay in the moment.
__Marilyn Hutchinson:__At other tournaments our mom had been to, she would get nervous. Jack would hit a bad shot, and she'd hide behind a tree or walk in. That day was different. After Jack eagled the 15th hole and we walked over to 16, the real applause for him started, and it had a flavor that seemed to say, He is our son. Well, Jack was Mom's son, too, and at that moment she wasn't shy about letting people know it. I remember her nudging a fellow standing next to her and saying, "That's my boy!"
Jim Nantz, 16th-hole announcer, CBS Sports: I was 26 years old and really just trying to survive. I was in my first year at CBS and had never laid eyes on Augusta until the beginning of that week. Late on Sunday I was off-the-charts nervous. I was in the tower at 16 all by myself, and when Jack eagled 15, the noise was tremendous. I realized all this was coming my way.
Needless to say, I had homeworked the 16th hole to death. I was very aware of what Jack had done there over the years -- a birdie there in '63, the 40-footer there in 1975, among other things. Thank goodness I had that information in my mind when he walked onto the tee.
As Nicklaus arrived at the 16th tee, the ever-changing leader board read:
Tom Watson: -6 through 15
Greg Norman: -5 through 13
__Jack Nicklaus:__I always looked forward to hitting the tee shot at 16 because you knew that a good shot would result in a birdie. You can play the tee shot more than one way. The hill on the right will carry the ball to the hole.
Jim Nantz: I talked up until the moment Jack was ready to take the club back, but then he backed off the shot. That's when I threw it to Tom Weiskopf. I asked Tom [a four-time Masters runner-up] what was going through Jack's mind. Tom's answer was wonderful: "If I knew what was going through Jack's mind, I would have won this tournament."
That line wouldn't have been possible if Jack hadn't interrupted himself and started over.
__Jack Nicklaus:__I chose a 5-iron and nailed the shot. I made no effort to follow the ball in the air; it was out of my hands. The TV guys noted that my eyes were bad and I couldn't see, but in truth the hole was behind a little rise, and the ball disappears from sight. You can't see where it ends up anyway. So I just bent over and got my tee. But I knew it was going to be close.
__Jack Nicklaus II:__When the ball was in the air, I said, "Be the right club." And Dad came right back: "It is."
Jack Nicklaus: It was as cocky a remark as I've ever made in my life.
__Jim Nantz:__The ball in flight looked so clear it was like a baseball. It was flying right at my tower, which is perfectly in line with the slope. It was clear when the ball was halfway there it was going to be a good shot. And when it landed and took the slope toward the hole, I felt certain it was going to be a hole-in-one.
Now, before the final round, I'd hustled down to 16 to see if they were using the traditional back-left hole location, and of course they were. I noted to Frank that it was a vulnerable hole location and asked him what I should say if someone were to make a hole-in-one. "Kid, this is a visual medium," he said. "You are to say nothing." I sort of gulped and said, "Yes, sir." It turned out the ball came within two inches of going in and stopped a few feet away.
__Frank Chirkinian:__Only a golfer can understand and enjoy the sounds we heard that day, and I'm not talking about the galleries. I'm talking about the sound of Jack Nicklaus hitting a golf ball. There was dead quiet when Jack hit, and his iron shots had a distinctive sound, a crispness that told you the shots were going to be great. Those sounds were amplified in my truck, and I heard them all day long. Unforgettable.
__Jack Nicklaus:__The ball almost went in the hole, but it did not stop dead. It went about 3½ feet by, and that putt was far from a gimme. I played it at the left edge, and I was very glad to get that one down.
Jack Nicklaus II: The noise when Dad holed out was unbelievable. It left my ears ringing. It seemed to be loudest during the walk from the 16th green to the 17th tee. The cheers were coming down on top of us, which is much louder than when you're off to the side or in the gallery itself. People were leaning over and shouting. It was overwhelming, really.
Back in the 15th fairway, Kite and Ballesteros prepared to play their second shots. Kite smiled incredulously at the sound coming from 16, and, after Tom Watson and Tommy Nakajima had cleared the green, played a brave second shot to within 20 feet. It now was Ballesteros' turn to play. His distance to the hole was 198 yards, only a 4-iron for the man who at the time was regarded as the best player in the game. Ballesteros has declined recent interviews but talked to Golf Digest in detail in September 2000.
__Seve Ballesteros:__The problem was not pressure. The problem was that I had to wait for Watson and Nakajima to putt out. While I was there, Nicklaus holed a birdie on the 16th. I had to wait a number of minutes. I was talking to my brother and decided to hit a 5-iron. Then I changed to a 4-iron. It was better to be long than short. All I had to do was put the ball out of the water, and the tournament was mine. Maybe overconfidence was the problem.
__Tom Kite:__Seve's shot was not as easy as it looked. His ball was slightly on the downslope of one of those mounds in the fairway.
Seve Ballesteros: I tried to hit a soft 4-iron. I hit a little behind the ball and, you know, I hit it in the water. Then everything went wrong for me.
Jack Nicklaus: I heard the noise. It was a loud roar with a deep groan underneath it. Not a nice sound. I've never wished anyone bad, but I knew exactly what had happened. People were yelling, "It's in the water! It's in the water" and I'm thinking, I know that.
Nick Price: The reaction of the people when Seve hit the ball in the water included a little cheering. It was only to express, "Hey, we've got a golf tournament now," but Seve heard those cheers, and it crushed him. When I saw the replays of him on the closing holes -- on 17, especially -- his acknowledgement of the gallery seems gracious, but there's also an element of sarcasm. That's my read on it, anyway.
Frank Chirkinian: It was one of the few times that a player was influenced not by something he saw, but something he heard.
Ken Venturi: There have been three great types of roars at Augusta. Arnold Palmer got wild, whooping roars. Ben Hogan got a roar that really was very loud, sustained applause. Jack that year had a roar unlike any other, and Seve got a full dose of it. It got into his head. If it had been any other player who had made the eagle at 15, Seve wouldn't have given a damn; he would have been over the water, easy.
Hogan always said there were three ways to beat somebody: You outwork them, you outhink them, and you intimidate them. Jack intimidated Seve, there's no way around it.
Jack Nicklaus: I think we all choke. As an amateur I played golf with a friend out in San Francisco named John Swanson. He needled me when the pressure was on. He'd say, "Is the globus hysterigus getting you Jack, a little freezing of the glottis?" A nonsense phrase suggesting you're choking. We all have that globus hysterigus, some apprehension under stress. Certainly I've choked. But if you can function with all that stuff going on around you, it is very much to your advantage.
__Seve Ballesteros:__Obviously I don't want to take anything away from Nicklaus' victory. He played great. I have to say it was destiny. I was destined not to win, and Jack was destined to finish his career with a great victory. He was finished by then; we all know that.
No question, that Masters really hurt my confidence a lot. If I had won there, instead of Nicklaus holding the record of six green jackets, it probably would have been Seve Ballesteros who would have had six.
After taking a drop, Ballesteros made a bogey. Kite two-putted for a birdie. Norman, meanwhile, birdied the 14th hole. There now was a three-way tie for the lead, with Nicklaus, Ballesteros and Kite all at eight under par, with Norman and Watson at six under. Nicklaus, following a poor drive at the 17th, faced a difficult shot to the green.
Verne Lundquist, 17th-hole announcer, CBS Sports: I always had a spotter to help me with club selection and yardage, which was signaled from the caddie. Jack had 125 yards to the green and had to play a low shot between two pines. He hit it 12 feet from the hole, really a super shot.
__Jack Nicklaus II:__It's hard to appreciate on TV how hard that putt on 17 was. The hole was on a crest where the ball could break either way. I took a look and told Dad I thought the ball would break a little to the right. He overruled me. He said, "No, Rae's Creek will keep it to the left." The ball started to go to the right, but it straightened out and went in.
__Sandy Lyle:__He knew he had to make it, and it was such a hard putt. Not only could it break either way, it would have been easy to hit it six feet past. And he just lasered it in there.
Verne Lundquist: When the putt fell, I exclaimed "Yes, sir!" I'd never used that expression before. Just a few years ago, Peter Kostis alerted me to the fact that Ben Wright had used the same expression earlier in the telecast. I'm sure the phrase was bubbling in my subconscious and just came out. The only conscious thought I had was to keep my reaction simple. Well, you can't get much simpler than "Yes, sir!"
As for the roar, it had the quality of a roar you hear in an enclosed arena, where the noise has nowhere to go. It was like the sound bounced off the sky and came back at us. It made my tower tremble.
For the first time, Jack Nicklaus had the lead in the 1986 Masters.
__Rick Reilly:__After Jack birdied 17, the place grew chaotic. I remember a woman in heels trying to climb a tree. Me, I was running around like an idiot. Play was spread out, and I wasn't sure where to go. There was a level of hysteria that was out of character for a golf tournament.
Nick Price: The roar from 17 when Jack's putt fell remains the loudest sound I've ever heard on a golf course. The noise, the people running in all directions, the energy in the air ... I've never experienced anything like it.
__Marilyn Hutchinson:__I remember running uphill to 17 and then 18, just rushing you know, and then it hit me that my mother was with us. I turned, and she was right there on our heels, running with us. She didn't look winded or a bit tired, which is amazing when you think about it.
__Jack Nicklaus II:__Dad needed that putt at 17 to take control of the golf tournament. Being in control means being able to dictate the way you play a hole. If Dad hadn't birdied 17, he would have been forced to try to birdie 18. The birdie at 17 gave him flexibility. He hit a 3-wood instead of a driver at 18, and he had options on the approach.
After Nicklaus drove safely into the fairway at the final hole, Kite and Ballesteros made difficult pars at the 16th. Norman had reached the 15th green in two. The leader board:
*Nicklaus: -9 through 17
Ballesteros: -8 through 16
Kite: -8 through 16
Norman: -6 through 14
Watson: -6 through 17
Jack Nicklaus: I felt if I could get in the clubhouse with a par, I'd either win the golf tournament or be in a playoff. On 18 I just wanted the ball in the fairway. A 3-wood left me with a straightforward shot. I still remember the yardage: 175 to the hole. It was a 5-iron, and I needed to get all of it to get the ball on the top level. I hit the ball really well, but just as it left the clubface I felt a little breeze in my face. The hole was all the way in the back of the green, and when the ball stopped on the lower tier I thought, Great, now I've got this darned putt.
It was a good 40 feet, but fortunately I knew what the putt did because our company had rebuilt that green, and I'd practiced that approach putt earlier in the week. Some of the greens had become too severe, and the back part of 18 was contoured too steeply from back to front. We'd leveled it out, and I knew that after the ball climbed the tier it would coast. The speed was crucial. And I got it just about right. I left it inches short.
Jack Nicklaus II: The first putt at 18 was the best shot he hit all day. What a hard putt that was. The pressure was still on, and if there was a moment where a mental lapse was likely, that long putt was it.
After he'd marked his ball so Sandy Lyle could putt out, I reminded him one last time, "Keep your head still." Dad smiled and said, "I can handle this one." And he rapped it in.
As Nicklaus exited the back of the green amid the longest, most prolonged applause in Masters history, he shook Lyle's hand and that of Lyle's caddie, Dave Musgrove. Jackie approached, and father and son embraced before disappearing into the gallery, their arms around each other.
Barbara Nicklaus: I'd gotten to the 18th hole late, and when Jack holed out my view was obscured. So I didn't see Jack give Jackie that hug. I saw it later on TV, and naturally I got emotional like everyone else.
Pat Summerall, 18th-hole announcer, CBS Sports: When Jack hugged Jackie, Venturi looked over at me and could see I was unable to speak. That's when he said, "Oh, beautiful" in his attempt to describe that scene. Ken wasn't much better off than I was. There were tears rolling down his cheeks. There were a lot of tears in the gallery, too. Everyone there knew they were experiencing something special.
__Ken Venturi:__I cry at Kmart openings. I mean, I'm the worst. So to see something like that was too much. But I did a pretty good job of getting back into it. There was still a lot of golf left to play.
Norman, who had two-putted No. 15 for a birdie, hit his tee shot stiff at the 16th hole for another birdie as Nicklaus was holing out on 18. Ballesteros, who had pulled his approach shot to the 17th hole badly to the left, three-putted for a fatal bogey. Kite, meanwhile, two-putted for a par. The leader board read:
Ballesteros: -7 through 17*
Kite found the fairway on 18 and played a terrific 6-iron to within 10 feet of the hole. Norman then contemplated his second shot on 17, having pulled his drive badly to the left.
Greg Norman: When I was a kid, I used to practice hitting leaves, branches and twigs off trees, and that would teach me my flight trajectory with different clubs. On 17 I had a straight shot to the pin, about 14, 15 inches of room to the left of the front greenside bunker. I picked out a limb, and I knew if I went under this little knot, I had this little window to go through. I couldn't see the flag, couldn't see the green. I just took a 5-iron and hit at that spot.
It was a good shot, and lucky, too, because the ball had to land short of the green and bounce forward and go straight, and just miss that bunker. I'd probably put it in the top half-dozen shots I ever played.
Norman's shot stopped 12 feet below the hole. But the man of the moment was Kite, who had a 10-foot birdie putt at 18 to force a playoff.
Jack Nicklaus: When I finished, I went to the Jones Cabin to wait it out. The TV was on, and I sat on the couch and watched for a while. When Norman kept making birdies, I said, "I can't watch this sitting down. I've got to stand up." I watched the rest standing behind the couch.
Kite had left a birdie putt short on the 14th hole, and as he stood over the ball, Venturi told the TV audience, "This is one putt here ... don't be short." Kite's putt lost speed at the end, took the break and stopped hole-high on the left.
Tom Kite: I made the putt. It just didn't go in. Honest to God, I made it so many times in the practice rounds -- seven or eight times -- and it never broke left once.
Ken Venturi: Kite wasn't in a situation where he could three-putt and lose, it was one where if he two-putted he'd lose. It was a must-make, and the one thing he had to do was get the ball to the hole. Yet somehow he didn't hit the ball firmly enough to hold the line. It was a mental error, that's all.
Now it was up to Norman. He holed the 12-footer at 17 for his fourth consecutive birdie, eliciting another "Yes, sir!" from Lundquist. After playing a 3-wood from the 18th tee, Norman had 186 yards to the hole. After waiting for Bernhard Langer and Donnie Hammond to clear the green, Norman chose a 4-iron. But he sailed the ball into the gallery right of the green.
__Greg Norman:__All day long I was aggressive with my iron play. Full swings, hard swings. My philosophy when I played the game was, the more you're under pressure, the harder you hit it.
I decided to take a 4-iron out because I wanted to get up on the back level; I didn't want to leave myself that 90-foot putt up the slope. I just said I'll cut a 4-iron, back off it a little. But on the upslope on the 18th at Augusta, if you back off, your hip speed is not going up the hill fast enough, you're going to lean back, and that's exactly what happened. In hindsight, it was just a bad mental mistake, a bad judgment call.
__Ken Venturi:__It was a shocking thing to see. Remember, this was before [Bob] Tway holed the bunker shot on Norman, before [Larry] Mize chipped in, before [Robert] Gamez holed the 7-iron, all of that.
So when Norman missed not only the green but also the gallery, I didn't know what to say. From that spot in the fairway I would bet he'd make 10 birdies for every bogey. The pitch wasn't very good, either.
Jack Nicklaus: Later that year, when Greg led the British Open at Turnberry after three rounds, I found him that Saturday night. I said, "Remember the swing you made at the last hole at Augusta, and the position you put yourself in? When you come down the stretch tomorrow, don't put the club in that position again. You may use what I'm telling you or not use it, I'm just telling you."
Greg won the next day. I don't know if my advice helped him or not, but I did want to pass it along.
__Greg Norman:__I made an equally bad judgment on the chip shot. I was probably about 12 to 15 feet from the green, and I should have putted the ball, simple as that. I should have just gotten the ball going down the hill. And the reason I decided not to was because when they cleared away all the stools people had been sitting on all day, the legs of the stools left little pockmarks.
Norman's chip stopped 10 feet above the hole, and after examining it from all angles, he missed the putt to the left. It was official: Jack Nicklaus had won his sixth Masters.
__Greg Norman:__You go to the Olympics, you work four years to get there, and you miss out by one one-hundredth of a second, and you get a bronze medal. You're a hero, wherever you go. Now, you finish second in a golf tournament, and because you didn't win you're a choker. I wanted to win the Masters, sure, but to do what I did to get a chance has to be worth something. I made one bad shot and did it in the heat of the battle. I live with it.
The Butler Cabin ceremony followed, at which chairman Hord Hardin complimented Sam Randolph, the only amateur to make the cut. Defending champion Bernhard Langer then helped Nicklaus into the green jacket.
Jack Nicklaus: In 1963 they put a jacket on me that was a 46 long. I was a 43 regular, and it came down past my wrists. The next time I came back they gave me Tom Dewey's [former governor of New York] jacket, and I wore that one for six or seven years. The club didn't offer me a jacket of my own, so eventually I had one made by Hart Schaffner and Marx. The material was a little different and the color was hard to get just right, but it was nice, and I wore it for years, 1986 included. When Jack Stephens [then Augusta National's chairman] found out in 1997 that my jacket wasn't ordered through the club, I found a note in my locker telling me to go to the pro shop and get measured. Today I have an authentic Augusta National green jacket.
For more than an hour as the presentation ceremonies and interviews took place and congratulations were offered, one of the players waited patiently for a quiet moment with Nicklaus.
__Greg Norman:__Jack Nicklaus was a big part of me being at the Masters at all. From 1976 to '86, I was gunning to do what he did. He wasn't going through a great time in '86, and I admired the way he dug deep through that adversity and focused for four days. After what he did on that back nine, I wanted to talk to him. When he came out of the Butler Cabin, I walked over and congratulated him. A few months later, when I won the Open at Turnberry, the first persons I saw were my caddie, Pete Bender, and then [wife] Laura. The third person there to congratulate me was Jack Nicklaus.
Tom Callahan, senior writer, Time Magazine, and now a contributing editor, Golf Digest: Nicklaus came into the interview room wearing his green jacket, and almost the first thing he said was, "Where's Tom McCollister?" Tom was off writing his game story for an early edition, so Jack explained about the article pinned on the refrigerator. A little later, McCollister showed up, and Nicklaus spotted him right away.
"Thanks, Tom," Jack said.
"Glad I could help," Tom said.
__Rick Reilly:__This was my first lead Masters story for SI, and when I sat to write, I couldn't believe what I was seeing around me. Sportswriters I thought were pretty good were frozen at their typewriters. One guy was clutching his haircut, muttering, "It's too big. ... It's too big."
I wasn't much better off. I had a huge pile of notes, and I sat there for a while. Another writer, Buddy Martin, came over and said, "Rick, put all those notes away and just write what you saw. Go over the notes later." I got out of there and wrote until 5 a.m., then added the things from my notes until 7 a.m. I got it done, and God bless Buddy Martin.
__Jim Nantz:__When I got to the area behind the cabins near the Par-3 Course, Ken Venturi pulled up. "Hey, Jimmy, jump in. I'll give you a ride, kid." As he started driving he said, "Young man, how old are you?" I told Ken I was 26. He said, "Let me tell you something. I'm going to predict that you may one day be the first man to call 50 Masters. But I will tell you this: You will never live to see a day greater than this one at Augusta."
__Pat Summerall:__I covered a lot of sports in my 35 years as a broadcaster. I covered more than a thousand NFL games alone, and 30 Masters. Of all that I did and saw, the '86 Masters was the most emotional thing I ever witnessed.
__Ken Venturi:__The three greatest moments in golf to me are winning the 1964 U.S. Open, captaining the 2000 Presidents Cup team and being at Augusta National to watch and announce the 1986 Masters.
Jack Nicklaus II: Last fall we were up at Muirfield Village. It was a cold day, and we were hitting drivers on the range. Dad sidled over to watch me. I'm not super long, but after a few shots he said in a quiet voice, "If I could hit my driver like that, I could still win the Masters."
It's true. His distance control with his irons is terrific. He chips extremely well, and he has zero nerves in his putting. If the course weren't so darned long, he could win the Masters.
Of course he could win. We're talking about my dad.
__Jack Nicklaus:__The 1986 Masters is among the handful of experiences that stand apart from the rest. Baltusrol in 1980 was wonderful. St. Andrews in 1978 was something. Muirfield in 1972, when I lost to Lee Trevino, the gallery was unbelievable. Those are the special ones, and none more special than Augusta in 1986.
Marilyn Hutchinson: We all attended a dinner at the club that night. After we got together at the main house for a while, Mom, my husband and the boys drove home. I told the boys about the days when Jack was a kid and used to go out the back door of the house with his bag on his shoulder, cutting through a neighbor's yard to get over to Scioto to practice. A lot of Jack stories. And then we sang all the songs Dad had liked: "My Blue Heaven," "Bye Bye Blackbird" and, of course, "Beautiful Ohio." We sang all the way to Columbus.

redpajama_set_name: RedPajamaCommonCrawl


text:
import tl = require('vsts-task-lib/task');
import path = require('path');
import Q = require('q');
var os = require('os');
var regedit = require('regedit');
var uuid = require('node-uuid');
var fs = require('fs');
var xml2js = require('xml2js');
var perf = require("performance-now")

const runSettingsExt = ".runsettings";
const testSettingsExt = ".testsettings";
const TIFriendlyName = "Test Impact";
const TICollectorURI = "datacollector://microsoft/TestImpact/1.0";
const TITestSettingsAgentNameTag = "testImpact-5d76a195-1e43-4b90-a6ce-4ec3de87ed25";
const TITestSettingsNameTag = "testSettings-5d76a195-1e43-4b90-a6ce-4ec3de87ed25";
const TITestSettingsIDTag = "5d76a195-1e43-4b90-a6ce-4ec3de87ed25";
const TITestSettingsXmlnsTag = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010"

try {
    tl.setResourcePath(path.join(__dirname, 'task.json'));
    var vsTestVersion: string = tl.getInput('vsTestVersion');
    var testAssembly: string = tl.getInput('testAssembly', true);
    var testFiltercriteria: string = tl.getInput('testFiltercriteria');
    var runSettingsFile: string = tl.getPathInput('runSettingsFile');
    var codeCoverageEnabled: boolean = tl.getBoolInput('codeCoverageEnabled');
    var pathtoCustomTestAdapters: string = tl.getInput('pathtoCustomTestAdapters');
    var overrideTestrunParameters: string = tl.getInput('overrideTestrunParameters');
    var otherConsoleOptions: string = tl.getInput('otherConsoleOptions');
    var testRunTitle: string = tl.getInput('testRunTitle');
    var platform: string = tl.getInput('platform');
    var configuration: string = tl.getInput('configuration');
    var publishRunAttachments: string = tl.getInput('publishRunAttachments');
    var runInParallel: boolean = tl.getBoolInput('runInParallel');
    var tiaEnabled = tl.getVariable('tia.enabled');

    tl._writeLine("##vso[task.logissue type=warning;TaskName=VSTest]");

    var sourcesDirectory = tl.getVariable('System.DefaultWorkingDirectory');
    var testAssemblyFiles = getTestAssemblies();

    if (testAssemblyFiles && testAssemblyFiles.size != 0) {
        var workingDirectory = path.join(sourcesDirectory, "..");
        getTestResultsDirectory(runSettingsFile, path.join(workingDirectory, 'TestResults')).then(function (resultsDirectory) {
            invokeVSTest(resultsDirectory)
                .then(function (code) {
                    try {
                        publishTestResults(resultsDirectory);
                        tl.setResult(code, tl.loc('VstestReturnCode', code));
                    }
                    catch (error) {
                        tl._writeLine("##vso[task.logissue type=error;code=" + error + ";TaskName=VSTest]");
                        throw error;
                    }
                })
                .fail(function (err) {
                    tl._writeLine("##vso[task.logissue type=error;code=" + err + ";TaskName=VSTest]");
                    throw err;
                });
        });
    }
    else {
        tl._writeLine("##vso[task.logissue type=warning;code=002004;]");
        tl.warning(tl.loc('NoMatchingTestAssemblies', testAssembly));
    }
}
catch (error) {
    tl._writeLine("##vso[task.logissue type=error;code=" + error + ";TaskName=VSTest]");
    throw error;
}

function getTestAssemblies(): Set<string> {
    var testAssemblyFiles = [];
    if (testAssembly.indexOf('*') >= 0 || testAssembly.indexOf('?') >= 0) {
        tl.debug('Pattern found in solution parameter.');
        var excludeTestAssemblies = [];
        var allFiles = tl.find(sourcesDirectory);
        var testAssemblyFilters = testAssembly.split(';');
        testAssemblyFilters.forEach(function (testAssemblyFilter) {
            if (testAssemblyFilter.startsWith("-:")) {
                if (testAssemblyFilter.indexOf('*') >= 0 || testAssemblyFilter.indexOf('?') >= 0) {
                    excludeTestAssemblies = excludeTestAssemblies.concat(getFilteredFiles(testAssemblyFilter.substr(2), allFiles));
                }
                else {
                    excludeTestAssemblies.push(testAssemblyFilter.substr(2));
                }
            }
            else if (testAssemblyFilter.indexOf('*') >= 0 || testAssemblyFilter.indexOf('?') >= 0) {
                testAssemblyFiles = testAssemblyFiles.concat(getFilteredFiles(testAssemblyFilter, allFiles));
            }
            else {
                testAssemblyFiles.push(testAssemblyFilter);
            }
        });
        testAssemblyFiles = testAssemblyFiles.filter(x => excludeTestAssemblies.indexOf(x) < 0);
    }
    else {
        tl.debug('No Pattern found in solution parameter.');
        var assemblies = testAssembly.split(';');
        assemblies.forEach(function (assembly) {
            testAssemblyFiles.push(assembly);
        });
    }
    return new Set(testAssemblyFiles);
}

function getVstestArguments(settingsFile: string): string[] {
    var argsArray: string[] = [];
    testAssemblyFiles.forEach(function (testAssembly) {
        var testAssemblyPath = testAssembly;
        //To maintain parity with the behaviour when test assembly was filepath, try to expand it relative to build sources directory.
        if (sourcesDirectory && !pathExistsAsFile(testAssembly)) {
            var expandedPath = path.join(sourcesDirectory, testAssembly);
            if (pathExistsAsFile(expandedPath)) {
                testAssemblyPath = expandedPath;
            }
        }
        argsArray.push(testAssemblyPath);
    });
    if (testFiltercriteria) {
        argsArray.push("/TestCaseFilter:" + testFiltercriteria);
    }
    if (settingsFile && pathExistsAsFile(settingsFile)) {
        argsArray.push("/Settings:" + settingsFile);
    }
    if (codeCoverageEnabled) {
        argsArray.push("/EnableCodeCoverage");
    }
    if (otherConsoleOptions) {
        argsArray.push(otherConsoleOptions);
    }
    argsArray.push("/logger:trx");
    if (pathtoCustomTestAdapters) {
        if (pathExistsAsDirectory(pathtoCustomTestAdapters)) {
            argsArray.push("/TestAdapterPath:\"" + pathtoCustomTestAdapters + "\"");
        }
        else {
            argsArray.push("/TestAdapterPath:\"" + path.dirname(pathtoCustomTestAdapters) + "\"");
        }
    }
    else if (sourcesDirectory && isNugetRestoredAdapterPresent(sourcesDirectory)) {
        argsArray.push("/TestAdapterPath:\"" + sourcesDirectory + "\"");
    }
    return argsArray;
}

function addVstestArgs(argsArray: string[], vstest: any) {
    argsArray.forEach(function (arr) {
        vstest.arg(arr);
    });
}

function updateResponseFile(argsArray: string[], responseFile: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    fs.appendFile(responseFile, os.EOL + argsArray.join(os.EOL), function (err) {
        if (err) {
            defer.reject(err);
        }
        defer.resolve(responseFile);
    });
    return defer.promise;
}

function getTestSelectorLocation() : string {
    return path.join(__dirname, "TestSelector/TestSelector.exe");
}

function generateResponseFile(): Q.Promise<string> {
    var startTime = perf();
    var endTime : number;
    var elapsedTime : number;
    var defer = Q.defer<string>();
    var tempFile = path.join(os.tmpdir(), uuid.v1() + ".txt");
    tl.debug("Response file will be generated at " + tempFile);
    var selectortool = tl.createToolRunner(getTestSelectorLocation());
    selectortool.arg("GetImpactedtests");
    selectortool.arg("/TfsTeamProjectCollection:" + tl.getVariable("System.TeamFoundationCollectionUri"));
    selectortool.arg("/ProjectId:" + tl.getVariable("System.TeamProject"));
    selectortool.arg("/buildid:" + tl.getVariable("Build.BuildId"));
    selectortool.arg("/token:" + tl.getEndpointAuthorizationParameter("SystemVssConnection", "AccessToken", false));
    selectortool.arg("/responsefile:" + tempFile);
    selectortool.exec()
        .then(function (code) {
            endTime = perf();
            elapsedTime = endTime - startTime;
            tl._writeLine("##vso[task.logissue type=warning;SubTaskName=GenerateResponseFile;SubTaskDuration=" + elapsedTime + "]");
            tl.debug(tl.loc("GenerateResponseFilePerfTime", elapsedTime));
            defer.resolve(tempFile);
        })
        .fail(function (err) {
            defer.reject(err);
        });

    return defer.promise;
}

function publishCodeChanges(): Q.Promise<string> {
    var startTime = perf();
    var endTime : number;
    var elapsedTime: number;
    var defer = Q.defer<string>();
    var selectortool = tl.createToolRunner(getTestSelectorLocation());
    selectortool.arg("PublishCodeChanges");
    selectortool.arg("/TfsTeamProjectCollection:" + tl.getVariable("System.TeamFoundationCollectionUri"));
    selectortool.arg("/ProjectId:" + tl.getVariable("System.TeamProject"));
    selectortool.arg("/newdropPath:" + tl.getVariable("Build.SourcesDirectory"));
    selectortool.arg("/Definitionid:" + tl.getVariable("System.DefinitionId"));
    selectortool.arg("/buildid:" + tl.getVariable("Build.BuildId"));
    selectortool.arg("/token:" + tl.getEndpointAuthorizationParameter("SystemVssConnection", "AccessToken", false));

    selectortool.exec()
        .then(function(code) {
            endTime = perf();
            elapsedTime = endTime - startTime;
            tl._writeLine("##vso[task.logissue type=warning;SubTaskName=PublishCodeChanges;SubTaskDuration=" + elapsedTime + "]");
            tl.debug(tl.loc("PublishCodeChangesPerfTime", elapsedTime));
            defer.resolve(String(code));
        })
        .fail(function (err) {
            defer.reject(err);
        });

    return defer.promise;
}

function executeVstest(testResultsDirectory: string, parallelRunSettingsFile: string, vsVersion: number, argsArray: string[]): Q.Promise<number> {
    var defer = Q.defer<number>();
    var vsCommon = tl.getVariable("VS" + vsVersion + "0COMNTools");
    if (!vsCommon) {
        tl.error(tl.loc('VstestNotFound', vsVersion));
        defer.resolve(1);
        return defer.promise;
    }
    var vstestLocation = path.join(vsCommon, "..\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe");
    var vstest = tl.createToolRunner(vstestLocation);
    addVstestArgs(argsArray, vstest);

    tl.rmRF(testResultsDirectory, true);
    tl.mkdirP(testResultsDirectory);
    tl.cd(workingDirectory);
    vstest.exec({failOnStdErr: true})
        .then(function (code) {
            cleanUp(parallelRunSettingsFile);
            defer.resolve(code);
        })
        .fail(function (err) {
            cleanUp(parallelRunSettingsFile);
            tl.warning(tl.loc('VstestFailed'));
            tl.error(err);
            defer.resolve(1);
        });
    return defer.promise;
}

function runVStest(testResultsDirectory: string, settingsFile: string, vsVersion: number): Q.Promise<number> {
    var defer = Q.defer<number>();
    if (isTiaAllowed()) {
        publishCodeChanges()
            .then(function(status) {
                generateResponseFile()
                    .then(function (responseFile) {
                        if (isNonEmptyResponseFile(responseFile)) {
                            updateResponseFile(getVstestArguments(settingsFile), responseFile)
                                .then(function (updatedFile) {
                                    executeVstest(testResultsDirectory, settingsFile, vsVersion, ["@" + updatedFile])
                                        .then(function (code) {
                                            defer.resolve(code);
                                        })
                                        .fail(function (code) {
                                            defer.resolve(code);
                                        })
                                        .finally(function () {
                                            tl.debug("Deleting the response file " + responseFile)
                                            tl.rmRF(responseFile, true);
                                        });
                                })
                                .fail(function (err) {
                                    tl.error(err);
                                    tl.warning(tl.loc('ErrorWhileUpdatingResponseFile', responseFile));
                                    executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile))
                                        .then(function (code) {
                                            defer.resolve(code);
                                        })
                                        .fail(function (code) {
                                            defer.resolve(code);
                                        }).finally(function () {
                                            tl.debug("Deleting the response file " + responseFile)
                                            tl.rmRF(responseFile, true);
                                        });
                                });
                        }
                        else {
                            tl.debug("Empty response file detected. All tests will be executed.");
                            executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile))
                                .then(function (code) {
                                    defer.resolve(code);
                                })
                                .fail(function (code) {
                                    defer.resolve(code);
                                })
                                .finally(function () {
                                    tl.debug("Deleting the response file " + responseFile)
                                    tl.rmRF(responseFile, true);
                                });
                        }
                    })
                    .fail(function (err) {
                        tl.error(err);
                        tl.warning(tl.loc('ErrorWhileCreatingResponseFile'));
                        executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile))
                            .then(function (code) {
                                defer.resolve(code);
                            })
                            .fail(function (code) {
                                defer.resolve(code);
                            });
                    });
            })
            .fail(function (err){
                tl.error(err);
                tl.warning(tl.loc('ErrorWhilePublishingCodeChanges'));
                executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile))
                    .then(function (code) {
                        defer.resolve(code);
                    })
                    .fail(function (code) {
                        defer.resolve(code);
                    });
            });
    }
    else {
        tl.debug("Non TIA mode of test execution");
        executeVstest(testResultsDirectory, settingsFile, vsVersion, getVstestArguments(settingsFile))
            .then(function (code) {
                defer.resolve(code);
            })
            .fail(function (code) {
                defer.resolve(code);
            });
    }
    return defer.promise;
}

function invokeVSTest(testResultsDirectory: string): Q.Promise<number> {
    var defer = Q.defer<number>();
    if (vsTestVersion.toLowerCase() == "latest") {
        vsTestVersion = null;
    }
    overrideTestRunParametersIfRequired(runSettingsFile)
        .then(function (overriddenSettingsFile) {
            locateVSVersion()
                .then(function (vsVersion) {
                    setupSettingsFileForTestImpact(vsVersion, overriddenSettingsFile)
                        .then(function (runSettingswithTestImpact) {
                            setRunInParallellIfApplicable(vsVersion);
                            setupRunSettingsFileForParallel(runInParallel, runSettingswithTestImpact)
                                .then(function (parallelRunSettingsFile) {
                                    runVStest(testResultsDirectory, parallelRunSettingsFile, vsVersion)
                                        .then(function (code) {
                                            defer.resolve(code);
                                        })
                                        .fail(function (code) {
                                            defer.resolve(code);
                                        });
                                })
                                .fail(function (err) {
                                    tl.error(err);
                                    defer.resolve(1);
                                });
                        })
                        .fail(function (err) {
                            tl.error(err);
                            defer.resolve(1);
                        });
                })
                .fail(function (err) {
                    tl.error(err);
                    defer.resolve(1);
                });
        })
        .fail(function (err) {
            tl.error(err);
            defer.resolve(1);
        });

    return defer.promise;
}

function publishTestResults(testResultsDirectory: string) {
    if (testResultsDirectory) {
        var allFilesInResultsDirectory = tl.find(testResultsDirectory);
        var resultFiles = tl.match(allFilesInResultsDirectory, "*.trx", { matchBase: true });
        if (resultFiles && resultFiles.length != 0) {
            var tp = new tl.TestPublisher("VSTest");
            tp.publish(resultFiles, "false", platform, configuration, testRunTitle, publishRunAttachments);
        }
        else {
            tl._writeLine("##vso[task.logissue type=warning;code=002003;]");
            tl.warning(tl.loc('NoResultsToPublish'));
        }
    }
}

function getFilteredFiles(filesFilter: string, allFiles: string[]): string[] {
    if (os.type().match(/^Win/)) {
        return tl.match(allFiles, filesFilter, { matchBase: true, nocase: true });
    }
    else {
        return tl.match(allFiles, filesFilter, { matchBase: true });
    }
}

function cleanUp(temporarySettingsFile: string) {
    //cleanup the runsettings file
    if (temporarySettingsFile && runSettingsFile != temporarySettingsFile) {
        try {
            tl.rmRF(temporarySettingsFile, true);
        }
        catch (error) {
            //ignore. just cleanup.
        }
    }
}

function overrideTestRunParametersIfRequired(settingsFile: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    if (!settingsFile || !pathExistsAsFile(settingsFile) || !overrideTestrunParameters || overrideTestrunParameters.trim().length == 0) {
        defer.resolve(settingsFile);
        return defer.promise;
    }

    overrideTestrunParameters = overrideTestrunParameters.trim();
    var overrideParameters = {};

    var parameterStrings = overrideTestrunParameters.split(";");
    parameterStrings.forEach(function (parameterString) {
        var pair = parameterString.split("=", 2);
        if (pair.length == 2) {
            var key = pair[0];
            var value = pair[1];
            if (!overrideParameters[key]) {
                overrideParameters[key] = value;
            }
        }
    });

    readFileContents(runSettingsFile, "utf-8")
        .then(function (xmlContents) {
            var parser = new xml2js.Parser();
            parser.parseString(xmlContents, function (err, result) {
                if (err) {
                    tl.warning(tl.loc('ErrorWhileReadingRunSettings', err));
                    tl.debug("Error occured while overriding test run parameters. Continuing...");
                    defer.resolve(settingsFile);
                    return defer.promise;
                }

                if (result.RunSettings && result.RunSettings.TestRunParameters && result.RunSettings.TestRunParameters[0] &&
                    result.RunSettings.TestRunParameters[0].Parameter) {
                    var parametersArray = result.RunSettings.TestRunParameters[0].Parameter;
                    parametersArray.forEach(function (parameter) {
                        var key = parameter.$.name;
                        if (overrideParameters[key]) {
                            parameter.$.value = overrideParameters[key];
                        }
                    });
                    tl.debug("Overriding test run parameters.");
                    var builder = new xml2js.Builder();
                    var overridedRunSettings = builder.buildObject(result);
                    saveToFile(overridedRunSettings, runSettingsExt)
                        .then(function (fileName) {
                            defer.resolve(fileName);
                        })
                        .fail(function (err) {
                            tl.debug("Error occured while overriding test run parameters. Continuing...");
                            tl.warning(err);
                            defer.resolve(settingsFile);
                        });
                }
                else {
                    tl.debug("No test run parameters found to override.");
                    defer.resolve(settingsFile);
                }
            });
        })
        .fail(function (err) {
            tl.debug("Error occured while overriding test run parameters. Continuing...");
            tl.warning(err);
            defer.resolve(settingsFile);
        });
    return defer.promise;
}

function isNugetRestoredAdapterPresent(rootDirectory: string): boolean {
    var allFiles = tl.find(rootDirectory);
    var adapterFiles = tl.match(allFiles, "**\\packages\\**\\*TestAdapter.dll", { matchBase: true });
    if (adapterFiles && adapterFiles.length != 0) {
        for (var i = 0; i < adapterFiles.length; i++) {
            var adapterFile = adapterFiles[i];
            var packageIndex = adapterFile.indexOf('packages') + 7;
            var packageFolder = adapterFile.substr(0, packageIndex);
            var parentFolder = path.dirname(packageFolder);
            var solutionFiles = tl.match(allFiles, path.join(parentFolder, "*.sln"), { matchBase: true });
            if (solutionFiles && solutionFiles.length != 0) {
                return true;
            }
        }
    }
    return false;
}

function getTestResultsDirectory(settingsFile: string, defaultResultsDirectory: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    if (!settingsFile || !pathExistsAsFile(settingsFile)) {
        defer.resolve(defaultResultsDirectory);
        return defer.promise;
    }

    readFileContents(runSettingsFile, "utf-8")
        .then(function (xmlContents) {
            var parser = new xml2js.Parser();
            parser.parseString(xmlContents, function (err, result) {
                if (!err && result.RunSettings && result.RunSettings.RunConfiguration && result.RunSettings.RunConfiguration[0] &&
                    result.RunSettings.RunConfiguration[0].ResultsDirectory && result.RunSettings.RunConfiguration[0].ResultsDirectory[0].length > 0) {
                    var resultDirectory = result.RunSettings.RunConfiguration[0].ResultsDirectory[0];
                    resultDirectory = resultDirectory.trim();

                    if (resultDirectory) {
                        // path.resolve will take care if the result directory given in settings files is not absolute.
                        defer.resolve(path.resolve(path.dirname(runSettingsFile), resultDirectory));
                    }
                    else {
                        defer.resolve(defaultResultsDirectory);
                    }
                }
                else {
                    defer.resolve(defaultResultsDirectory);
                }
            });
        })
        .fail(function (err) {
            tl.debug("Error occured while reading test result directory from run settings. Continuing...")
            tl.warning(err);
            defer.resolve(defaultResultsDirectory);
        });
    return defer.promise;
}

function getTIAssemblyQualifiedName(vsVersion: number): String {
    return "Microsoft.VisualStudio.TraceCollector.TestImpactDataCollector, Microsoft.VisualStudio.TraceCollector, Version=" + vsVersion + ".0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
}

function getTestImpactAttributes(vsVersion: number) {
    return {
        uri: TICollectorURI,
        assemblyQualifiedName: getTIAssemblyQualifiedName(vsVersion),
        friendlyName: TIFriendlyName
    };
}

function isTestImapctCollectorPresent(dataCollectorArray): Boolean {
    var found = false;
    var tiaFriendlyName = TIFriendlyName.toUpperCase();
    for (var node of dataCollectorArray) {
        if (node.$.friendlyName && node.$.friendlyName.toUpperCase() === tiaFriendlyName) {
            tl.debug("Test impact data collector already present, will not add the node.");
            found = true;
            break;
        }
    }
    return found;
}

function updateRunSettings(result: any, vsVersion: number) {
    var dataCollectorNode = null;
    if (!result.RunSettings) {
        tl.debug("Updating runsettings file from RunSettings node");
        result.RunSettings = { DataCollectionRunSettings: { DataCollectors: { DataCollector: {} } } };
        dataCollectorNode = result.RunSettings.DataCollectionRunSettings.DataCollectors.DataCollector;
    }
    else if (!result.RunSettings.DataCollectionRunSettings) {
        tl.debug("Updating runsettings file from DataCollectionSettings node");
        result.RunSettings.DataCollectionRunSettings = { DataCollectors: { DataCollector: {} } };
        dataCollectorNode = result.RunSettings.DataCollectionRunSettings.DataCollectors.DataCollector;
    }
    else if (!result.RunSettings.DataCollectionRunSettings[0].DataCollectors) {
        tl.debug("Updating runsettings file from DataCollectors node");
        result.RunSettings.DataCollectionRunSettings[0] = { DataCollectors: { DataCollector: {} } };
        dataCollectorNode = result.RunSettings.DataCollectionRunSettings[0].DataCollectors.DataCollector;
    }
    else {
        var dataCollectorArray = result.RunSettings.DataCollectionRunSettings[0].DataCollectors[0].DataCollector;
        if (!dataCollectorArray) {
            tl.debug("Updating runsettings file from DataCollector node");
            result.RunSettings.DataCollectionRunSettings[0] = { DataCollectors: { DataCollector: {} } };
            dataCollectorNode = result.RunSettings.DataCollectionRunSettings[0].DataCollectors.DataCollector;
        }
        else {
            if (!isTestImapctCollectorPresent(dataCollectorArray)) {
                tl.debug("Updating runsettings file, adding a DataCollector node");
                dataCollectorArray.push({});
                dataCollectorNode = dataCollectorArray[dataCollectorArray.length - 1];
            }
        }
    }
    if (dataCollectorNode) {
        tl.debug("Setting attributes for test impact data collector");
        dataCollectorNode.$ = getTestImpactAttributes(vsVersion);
    }
}

function updateRunSettingsFileForTestImpact(vsVersion: number, settingsFile: string, exitErrorMessage: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    tl.debug("Adding test impact data collector element to runsettings file provided.");
    readFileContents(settingsFile, "utf-8")
        .then(function (xmlContents) {
            var parser = new xml2js.Parser();
            parser.parseString(xmlContents, function (err, result) {
                if (err) {
                    tl.warning(tl.loc('ErrorWhileReadingRunSettings', err));
                    tl.debug(exitErrorMessage);
                    defer.resolve(settingsFile);
                    return defer.promise;
                }
                if (result.RunSettings === undefined) {
                    tl.warning(tl.loc('ErrorWhileSettingTestImpactCollectorRunSettings'));
                    defer.resolve(settingsFile);
                    return defer.promise;
                }
                updateRunSettings(result, vsVersion);
                writeXmlFile(result, settingsFile, runSettingsExt, exitErrorMessage)
                    .then(function (filename) {
                        defer.resolve(filename);
                        return defer.promise;
                    });
            });
        })
        .fail(function (err) {
            tl.warning(err);
            tl.debug(exitErrorMessage);
            defer.resolve(settingsFile);
        });
    return defer.promise;
}

function updatTestSettings(result: any, vsVersion: number) {
    var dataCollectorNode = null;
    if (!result.TestSettings) {
        tl.debug("Updating testsettings file from TestSettings node");
        result.TestSettings = { Execution: { AgentRule: { DataCollectors: { DataCollector: {} } } } };
        result.TestSettings.Execution.AgentRule.$ = { name: TITestSettingsAgentNameTag };
        result.TestSettings.$ = { name: TITestSettingsNameTag, id: TITestSettingsIDTag, xmlns: TITestSettingsXmlnsTag };
        dataCollectorNode = result.TestSettings.Execution.AgentRule.DataCollectors.DataCollector;
    }
    else if (!result.TestSettings.Execution) {
        tl.debug("Updating testsettings file from Execution node");
        result.TestSettings.Execution = { AgentRule: { DataCollectors: { DataCollector: {} } } };
        result.TestSettings.Execution.AgentRule.$ = { name: TITestSettingsAgentNameTag };
        dataCollectorNode = result.TestSettings.Execution.AgentRule.DataCollectors.DataCollector;
    }
    else if (!result.TestSettings.Execution[0].AgentRule) {
        tl.debug("Updating testsettings file from AgentRule node");
        result.TestSettings.Execution[0] = { AgentRule: { DataCollectors: { DataCollector: {} } } };
        result.TestSettings.Execution[0].AgentRule.$ = { name: TITestSettingsAgentNameTag };
        dataCollectorNode = result.TestSettings.Execution[0].AgentRule.DataCollectors.DataCollector;
    }
    else if (!result.TestSettings.Execution[0].AgentRule[0].DataCollectors) {
        tl.debug("Updating testsettings file from DataCollectors node");
        result.TestSettings.Execution[0].AgentRule[0] = { DataCollectors: { DataCollector: {} } };
        dataCollectorNode = result.TestSettings.Execution[0].AgentRule[0].DataCollectors.DataCollector;
    }
    else {
        var dataCollectorArray = result.TestSettings.Execution[0].AgentRule[0].DataCollectors[0].DataCollector;
        if (!dataCollectorArray) {
            tl.debug("Updating testsettings file from DataCollector node");
            result.TestSettings.Execution[0].AgentRule[0].DataCollectors[0] = { DataCollector: {} };
            dataCollectorNode = result.TestSettings.Execution[0].AgentRule[0].DataCollectors[0].DataCollector;
        }
        else {
            if (!isTestImapctCollectorPresent(dataCollectorArray)) {
                tl.debug("Updating testsettings file, adding a DataCollector node");
                dataCollectorArray.push({});
                dataCollectorNode = dataCollectorArray[dataCollectorArray.length - 1];
            }
        }
    }
    if (dataCollectorNode) {
        tl.debug("Setting attributes for test impact data collector");
        dataCollectorNode.$ = getTestImpactAttributes(vsVersion);
    }
}

function writeXmlFile(result: any, settingsFile: string, fileExt: string, exitErrorMessage: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    var builder = new xml2js.Builder();
    var runSettingsForTestImpact = builder.buildObject(result);
    saveToFile(runSettingsForTestImpact, fileExt)
        .then(function (fileName) {
            cleanUp(settingsFile);
            defer.resolve(fileName);
            return defer.promise;
        })
        .fail(function (err) {
            tl.debug(exitErrorMessage);
            tl.warning(err);
            defer.resolve(settingsFile);
        });
    return defer.promise;
}

function updateTestSettingsFileForTestImpact(vsVersion: number, settingsFile: string, exitErrorMessage: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    tl.debug("Adding test impact data collector element to testsettings file provided.");
    readFileContents(settingsFile, "utf-8")
        .then(function (xmlContents) {
            var parser = new xml2js.Parser();
            parser.parseString(xmlContents, function (err, result) {
                if (err) {
                    tl.warning(tl.loc('ErrorWhileReadingTestSettings', err));
                    tl.debug(exitErrorMessage);
                    defer.resolve(settingsFile);
                    return defer.promise;
                }
                if (result.TestSettings === undefined) {
                    tl.warning(tl.loc('ErrorWhileSettingTestImpactCollectorTestSettings'));
                    defer.resolve(settingsFile);
                    return defer.promise;
                }
                updatTestSettings(result, vsVersion);
                writeXmlFile(result, settingsFile, testSettingsExt, exitErrorMessage)
                    .then(function (filename) {
                        defer.resolve(filename);
                        return defer.promise;
                    });
            });
        })
        .fail(function (err) {
            tl.warning(err);
            tl.debug(exitErrorMessage);
            defer.resolve(settingsFile);
        });
    return defer.promise;
}

function createRunSettingsForTestImpact(vsVersion: number, settingsFile: string, exitErrorMessage: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    tl.debug("No settings file provided or the provided settings file does not exist. Creating run settings file for enabling test impact data collector.");
    var runSettingsForTIA = '<?xml version="1.0" encoding="utf-8"?><RunSettings><DataCollectionRunSettings><DataCollectors>' +
        '<DataCollector uri="' + TICollectorURI + '" ' +
        'assemblyQualifiedName="' + getTIAssemblyQualifiedName(vsVersion) + '" ' +
        'friendlyName="' + TIFriendlyName + '"/>' +
        '</DataCollectors></DataCollectionRunSettings></RunSettings>';
    saveToFile(runSettingsForTIA, runSettingsExt)
        .then(function (fileName) {
            defer.resolve(fileName);
            return defer.promise;
        })
        .fail(function (err) {
            tl.debug(exitErrorMessage);
            tl.warning(err);
            defer.resolve(settingsFile);
        });
    return defer.promise;
}

function setupSettingsFileForTestImpact(vsVersion: number, settingsFile: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    var exitErrorMessage = "Error occured while setting in test impact data collector. Continuing...";
    if (isTiaAllowed()) {
        if (settingsFile && settingsFile.split('.').pop().toLowerCase() == "testsettings") {
            updateTestSettingsFileForTestImpact(vsVersion, settingsFile, exitErrorMessage)
                .then(function (updatedFile) {
                    defer.resolve(updatedFile);
                    return defer.promise;
                });
        }
        else if (!settingsFile || settingsFile.split('.').pop().toLowerCase() != "runsettings" || !pathExistsAsFile(settingsFile)) {
            createRunSettingsForTestImpact(vsVersion, settingsFile, exitErrorMessage)
                .then(function (updatedFile) {
                    defer.resolve(updatedFile);
                    return defer.promise;
                });
        }
        else {
            updateRunSettingsFileForTestImpact(vsVersion, settingsFile, exitErrorMessage)
                .then(function (updatedFile) {
                    defer.resolve(updatedFile);
                    return defer.promise;
                });
        }
    }
    else {
        tl.debug("Settings are not sufficient for setting test impact. Not updating the settings file");
        defer.resolve(settingsFile);
    }
    return defer.promise;
}

function setupRunSettingsFileForParallel(runInParallel: boolean, settingsFile: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    var exitErrorMessage = "Error occured while setting run in parallel. Continuing...";
    if (runInParallel) {
        if (settingsFile && settingsFile.split('.').pop().toLowerCase() == "testsettings") {
            tl.warning(tl.loc('RunInParallelNotSupported'));
            defer.resolve(settingsFile);
            return defer.promise;
        }

        if (!settingsFile || settingsFile.split('.').pop().toLowerCase() != "runsettings" || !pathExistsAsFile(settingsFile)) {
            tl.debug("No settings file provided or the provided settings file does not exist.");
            var runSettingsForParallel = '<?xml version="1.0" encoding="utf-8"?><RunSettings><RunConfiguration><MaxCpuCount>0</MaxCpuCount></RunConfiguration></RunSettings>';
            saveToFile(runSettingsForParallel, runSettingsExt)
                .then(function (fileName) {
                    defer.resolve(fileName);
                    return defer.promise;
                })
                .fail(function (err) {
                    tl.debug(exitErrorMessage);
                    tl.warning(err);
                    defer.resolve(settingsFile);
                });
        }
        else {
            tl.debug("Adding maxcpucount element to runsettings file provided.");
            readFileContents(settingsFile, "utf-8")
                .then(function (xmlContents) {
                    var parser = new xml2js.Parser();
                    parser.parseString(xmlContents, function (err, result) {
                        if (err) {
                            tl.warning(tl.loc('ErrorWhileReadingRunSettings', err));
                            tl.debug(exitErrorMessage);
                            defer.resolve(settingsFile);
                            return defer.promise;
                        }

                        if (result.RunSettings === undefined) {
                            tl.warning(tl.loc('FailedToSetRunInParallel'));
                            defer.resolve(settingsFile);
                            return defer.promise;
                        }

                        if (!result.RunSettings) {
                            result.RunSettings = { RunConfiguration: { MaxCpuCount: 0 } };
                        }
                        else if (!result.RunSettings.RunConfiguration || !result.RunSettings.RunConfiguration[0]) {
                            result.RunSettings.RunConfiguration = { MaxCpuCount: 0 };
                        }
                        else {
                            var runConfigArray = result.RunSettings.RunConfiguration[0];
                            runConfigArray.MaxCpuCount = 0;
                        }

                        var builder = new xml2js.Builder();
                        var runSettingsForParallel = builder.buildObject(result);
                        saveToFile(runSettingsForParallel, runSettingsExt)
                            .then(function (fileName) {
                                cleanUp(settingsFile);
                                defer.resolve(fileName);
                                return defer.promise;
                            })
                            .fail(function (err) {
                                tl.debug(exitErrorMessage);
                                tl.warning(err);
                                defer.resolve(settingsFile);
                            });
                    });
                })
                .fail(function (err) {
                    tl.warning(err);
                    tl.debug(exitErrorMessage);
                    defer.resolve(settingsFile);
                });
        }
    }
    else {
        defer.resolve(settingsFile);
    }

    return defer.promise;
}

function saveToFile(fileContents: string, extension: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    var tempFile = path.join(os.tmpdir(), uuid.v1() + extension);
    fs.writeFile(tempFile, fileContents, function (err) {
        if (err) {
            defer.reject(err);
        }
        tl.debug("Temporary runsettings file created at " + tempFile);
        defer.resolve(tempFile);
    });
    return defer.promise;
}

function setRunInParallellIfApplicable(vsVersion: number) {
    if (runInParallel) {
        if (!isNaN(vsVersion) && vsVersion >= 14) {
            if (vsVersion >= 15) { // moved away from taef
                return;
            }

            // in 14.0 taef parellization needed taef enabled
            var vs14Common = tl.getVariable("VS140COMNTools");
            if (vs14Common && pathExistsAsFile(path.join(vs14Common, "..\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\TE.TestModes.dll"))) {
                setRegistryKeyForParallelExecution(vsVersion);
                return;
            }
        }
        resetRunInParallel();
    }
}

function resetRunInParallel() {
    tl.warning(tl.loc('UpdateOneOrHigherRequired'));
    runInParallel = false;
}

function locateVSVersion(): Q.Promise<number> {
    var defer = Q.defer<number>();
    var vsVersion = parseFloat(vsTestVersion);
    if (!isNaN(vsVersion)) {
        defer.resolve(vsVersion);
        return defer.promise;
    }
    var regPath = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio";
    regedit.list(regPath).on('data', function (entry) {
        if (entry && entry.data && entry.data.keys) {
            var subkeys = entry.data.keys;
            var versions = getFloatsFromStringArray(subkeys);
            if (versions && versions.length > 0) {
                versions.sort((a, b) => a - b);
                defer.resolve(versions[versions.length - 1]);
                return defer.promise;
            }
        }
        defer.resolve(null);
    });
    return defer.promise;
}

function getFloatsFromStringArray(inputArray: string[]): number[] {
    var outputArray: number[] = [];
    var count;
    if (inputArray) {
        for (count = 0; count < inputArray.length; count++) {
            var floatValue = parseFloat(inputArray[count]);
            if (!isNaN(floatValue)) {
                outputArray.push(floatValue);
            }
        }
    }
    return outputArray;
}

function setRegistryKeyForParallelExecution(vsVersion: number) {
    var regKey = "HKCU\\SOFTWARE\\Microsoft\\VisualStudio\\" + vsVersion.toFixed(1) + "_Config\\FeatureFlags\\TestingTools\\UnitTesting\\Taef";
    regedit.createKey(regKey, function (err) {
        if (!err) {
            var values = {
                [regKey]: {
                    'Value': {
                        value: '1',
                        type: 'REG_DWORD'
                    }
                }
            };
            regedit.putValue(values, function (err) {
                if (err) {
                    tl.warning(tl.loc('ErrorOccuredWhileSettingRegistry', err));
                }
            });
        } else {
            tl.warning(tl.loc('ErrorOccuredWhileSettingRegistry', err));
        }
    });
}

function readFileContents(filePath: string, encoding: string): Q.Promise<string> {
    var defer = Q.defer<string>();

    fs.readFile(filePath, encoding, (err, data) => {
        if (err) {
            defer.reject(new Error('Could not read file (' + filePath + '): ' + err.message));
        }
        else {
            defer.resolve(data);
        }
    });

    return defer.promise;
}

function pathExistsAsFile(path: string) {
    return tl.exist(path) && tl.stats(path).isFile();
}

function pathExistsAsDirectory(path: string) {
    return tl.exist(path) && tl.stats(path).isDirectory();
}

function isNonEmptyResponseFile(responseFile: string): boolean {
    if (pathExistsAsFile(responseFile) && tl.stats(responseFile).size) {
        return true;
    }
    return false;
}

function isTiaAllowed(): boolean {
    if (tiaEnabled && tiaEnabled.toUpperCase() == "TRUE" && getTestSelectorLocation()) {
        return true;
    }
    return false;
}

redpajama_set_name: RedPajamaGithub


Partly cloudy in the morning with moderate winds from the NNE. Light rain shower in the afternoon with moderate winds from the S.
Partly cloudy in the morning with moderate winds from the NNE. Partly cloudy in the afternoon with moderate winds from the SSW.
top plus South windswell fading .
Partly cloudy in the morning with moderate winds from the N. Partly cloudy in the afternoon with moderate winds from the WSW.
Partly cloudy in the morning with light winds from the N. Partly cloudy in the afternoon with moderate winds from the SW.
Partly cloudy in the morning with light winds from the NNE. Partly cloudy in the afternoon with moderate winds from the SW.
Partly cloudy in the morning with light winds from the NNW. Partly cloudy in the afternoon with light winds from the NNE.


text:
Il Fairey Spearfish era un aerosilurante imbarcato, sviluppato dall'azienda inglese Fairey Aviation negli anni quaranta per la Fleet Air Arm, e rimasto allo stadio di prototipo. Tale velivolo era destinato all'imbarco sulle nuove portaerei delle classi Malta e Audacious, ma la sua acquisizione venne cancellata poco dopo la fine della seconda guerra mondiale. Fu il più grande velivolo monomotore di sempre ad operare da una portaerei britannica.

Storia del progetto
L'aerosilurante Spearfish venne progettato dall'ufficio tecnico della Fairey Aviation in risposta alla Specifica 0.5/43 emessa dall'Ammiragliato. Il progetto teneva conto dei problemi emersi con il precedente Barracuda, era dotato di un motore più potente e di un radar antisommergibile posizionato all'interno della fusoliera (la sua installazione esterna sul Barracuda aveva provocato problemi di stabilità longitudinale). A causa di problemi legati allo sviluppo del propulsore radiale Bristol Centaurus il primo volo del prototipo (RA 356) avvenne in ritardo sui tempi previsti, il 5 luglio 1945, e l'aereo ottenne un ordine di produzione pari a 152 esemplari Un mese dopo la resa del Giappone e la fine della guerra l'ordine di produzione ridotto a quattro esemplari di preserie e 40 di serie.

Il secondo esemplare (RN 241), costruito a Stockport, volò per la prima volta il 29 dicembre 1945 sull'aeroporto di Manchester-Ringway. Ulteriori due esemplari vennero costruiti presso la fabbrica Fairey di Hayes (Middlesex) nel 1947, mentre il quinto velivolo fu assemblato a Stockport, ma non volò mai.
Durante i collaudi di volo del secondo esemplare il pilota ebbe seri problemi, non riuscendo a lanciare il siluro dovette rientrare alla base con l'arma armata e pronta ad esplodere, e con la stiva ventrale aperta. Gli ingegneri della Fairey ovviarono subito al problema, ma il danno di immagine era ormai fatto e l'aerosilurante perse la fiducia degli alti comandi della Fleet Air Arm, e non venne accettato per il servizio operativo. Dopo la fine della guerra, e con un più avanzato velivolo anti-sommergibile a turboelica (evolutosi poi nel Fairey Gannet) in corso di sviluppo, ogni ulteriore lavoro sul progetto venne fermato.

Descrizione tecnica

Il Fairey Spearfish era un monoplano monomotore, dalla struttura interamente metallica; la fusoliera a semimonoscocca, aveva sezione ovale. L'ala a sbalzo era in posizione mediana, posizionata in corrispondenza della cabina di pilotaggio. Essa ospitava, allineati, i due membri dell'equipaggio. Oltre al pilota, era presente un mitragliere/puntatore. I piani di coda erano di tipo classico con gli stabilizzatori orizzontali situati alla base della deriva.

Il carrello d'atterraggio era di tipo triciclo posteriore, con tutti e tre gli elementi retrattili. Le gambe principali si ritraevano all'interno della struttura alare con movimento laterale diretto verso le estremità, mentre il ruotino di coda si ritraeva all'interno di un apposito vano. All'estremità posteriore della fusoliera era presente il gancio d'arresto per l'appontaggio sulle portaerei.

Il propulsore impiegato era un radiale Bristol Centaurus 47 a 18 cilindri a doppia stella, raffreddato ad aria. La potenza erogata era pari a 2 585  CV (pari a circa 1 930 kW), ed azionava un'elica pentapala metallica "Rotol" VH-65 a passo variabile in volo.

L'armamento difensivo si basava su quattro mitragliatrici Browning M2 calibro 12.7 mm (0.50 in). Due mitragliatrici erano installate nelle ali, una per semiala, mentre due erano installate in una torretta difensiva girevole telecomandata Frazer-Nash FN95 azionata elettricamente, posizionata nella parte dorsale posteriore della fusoliera. Il carico offensivo massimo trasportabile all'interno della stiva ventrale prevedeva un siluro o 907 kg (2 000 lb) di bombe. Sotto le ali potevano essere installati un massimo di 16 razzi RP-3 da 127 mm, montati su apposite rotaie di lancio. Sugli esemplari di serie era prevista l'installazione del radar di scoperta aeronavale ASV Mk.XV.

Impiego operativo
L'Ammiragliato inglese non accettò l'aereo per l'impiego operativo. Un velivolo fu utilizzato dalla Royal Navy Carrier Trials Unit a Ford, Sussex, fino alla metà del 1952, mentre un altro venne modificato dalla Napier di Luton per la ricerca sui metodi di ottenimento dell'accumulo di ghiaccio artificiale.
Durante i collaudi emerse che l'aereo aveva i comandi di volo talmente pesanti che, in caso di maltempo, un pilota che doveva circuitare in attesa dell'atterraggio avrebbe dovuto volare su un così ampio circuito che avrebbe perso di vista la portaerei. L'esemplare RN 241 rimase sempre presso gli stabilimenti Fairey di Ringway per effettuare attività sperimentale, venendo successivamente demolito nei primi anni cinquanta.
In risposta alla Specifica 0.21/44 relativa ad un cacciabombardiere imbarcato biposto, lo Spearfish venne riprogettato per ospitare l'accoppiamento tra un motore in linea Rolls Royce Merlin e due eliche controrotanti. Per accelerarne la produzione venne considerato l'uso di altri motori, e se anche nel 1944 ne furono ordinati tre esemplari, il programma venne successivamente accantonato e quindi cancellato.

Note

Bibliografia

Periodici

Voci correlate
 Blackburn Firebrand
 Blackburn Firecrest
 Curtiss XBT2C
 Douglas A-1 Skyraider
 Douglas TB2D Skypirate
 Grumman AF Guardian
 Grumman TBF Avenger
 Martin AM Mauler
 Westland Wyvern

Altri progetti

Collegamenti esterni

Aerei militari della seconda guerra mondiale
Aerei militari dal 1931 al 1945
Aerei militari britannici

redpajama_set_name: RedPajamaWikipedia


text:
Q: Add a default text value for an ArrayList parameter in java I have the following code
    String str = "INSERT INTO EMPLOYEEDATA(USER,EMPID,IDNUM,IDDESC) VALUES(?,?,?,?);

    sql.append(str);
    ((ArrayList)parameters).add(user);
    ((ArrayList)parameters).add(empid);
    ((ArrayList)parameters).add(idnum);
    ((ArrayList)parameters).add("EMPLOYEE"-iddesc);

I'm trying to add the text "EMPLOYEE" before the string iddesc and insert it to the database.
String iddesc:
String iddesc = empid.substring(Math.max(0, empid.length() - 4));

The data that should be inserted to the table would be something like this
USER - SAI
EMPID - 123456789
IDNUM - 987456
IDDESC - EMPLOYEE-6789

Please can someone help me on how to achieve output.

redpajama_set_name: RedPajamaStackExchange


Outbox , a creative jungle is an expo of Europe's finest advertising, branding & digital work.
Creative Club of Belgium teamed up with Antwerp. Powered by Creatives. to bring the best creative output from Europe within the communication and design industry together. With the support of eurobest, festival of creativity that will be held in Antwerp from December 1-3. OUTBOX pays homage to the campaigns that win gold and silver medals on the eurobest festival and to the winners of the 32nd CCB Awards of the Creative Club of Belgium.
The greatest poster designs joined by the wittiest radio ads, the most innovative press campaigns and the coolest high-end design publicity: this expo brings you the finest, funniest, best and brightest of European and Belgian advertising with a special celebration of ideas that are born in Antwerp. A visit to OUTBOX will be a great discovery of our creative talents.
On December 24th and December 31st the exhibition will close at 16h.
The exhibition is closed on December 25th and January 1st & 2nd.


text:
Woodburn est une ville américaine, située dans le comté de Marion dans l'Oregon, dont la population était en 2000 de  habitants.

Personnalité notable
 Dorothy Olsen

Lien externe
 Site officiel de la ville

Ville en Oregon
Localité dans le comté de Marion (Oregon)


Mahaveer Records are proud to present the highly anticipated brand new single released by Subaig Singh entitled "She Dances" featuring Desi Routz!
Mahaveer Records are proud to present the brand new single released by Subaig Singh entitled "137 Speed", music by Popsy!
ARE YOU Subaig Singh? Contact us to get a featured artist profile page.


This Botanical Steam is intended to help reduce inflammation and hydrate your skin.
Place 1-2 tablespoons of blend into a large bowl, cover with 3-4 cups of boiling water. Drape a towel over your head to capture steam. Enjoy the gentle heat and aroma for 10-15 min as the herbs gently purify + cleanse your pores. When finished you can reuse the floral water by adding it to a clay mask for a full facial treatment.