A sniper would never get in closer against a machine gunner it makes no sense.
That's kind of the point. A sniper is only used for sniping from long, hidden spots, far from the enemy.
The machine gunner would have to find a way to make it to the sniper without being picked off along the way.
Unless the machine gun has a really long range.