From 15935286c08473ff39a1072a29173adc9b0465a9 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 23 Sep 2015 16:21:44 -0400 Subject: [PATCH] Replace hack to obtain full path We can obtain the full path of the executable using File#getAbsolutePath(). This is much better than the hack that was actually doing a launch to ask GDB where the binary was. I cannot explain why I didn't use this in the original implementation. Change-Id: Ifa0d538919cd0c231547f1f3e9c4b72837df4257 --- .../LaunchConfigurationAndRestartTest.java | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java index 9775a9e0906..e59f3ea2794 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Ericsson and others. + * Copyright (c) 2011, 2015 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -44,8 +45,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchManager; import org.junit.Ignore; import org.junit.Test; @@ -119,17 +118,6 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase { if (fServicesTracker != null) fServicesTracker.dispose(); } - - // HACK to get the full path of the program, which we need in other - // tests. There must be a proper eclipse way to do this! - private static String fFullProgramPath; - @Test - public void getFullPath() throws Throwable { - doLaunch(); - MIStoppedEvent stopped = getInitialStoppedEvent(); - fFullProgramPath = stopped.getFrame().getFullname(); - } - // ********************************************************************* // Below are the tests for the launch configuration. // ********************************************************************* @@ -141,10 +129,9 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase { */ @Test public void testSettingWorkingDirectory() throws Throwable { - IPath path = new Path(fFullProgramPath); - String dir = path.removeLastSegments(4).toPortableString() + "/" + EXEC_PATH; + String dir = new File(EXEC_PATH).getAbsolutePath(); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, dir); - setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + EXEC_NAME); + setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + "/" + EXEC_NAME); doLaunch();