Rework the cflags test so it works cross platform.

Rather than using optimization flags to test cflags,
use our own explicit defined flag.  This is better than
depending on __OPTIMIZE__.

R=phajdan.jr@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/23140009

git-svn-id: http://gyp.googlecode.com/svn/trunk@1698 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/test/cflags/cflags.c b/test/cflags/cflags.c
index c1e2452..276abe6 100644
--- a/test/cflags/cflags.c
+++ b/test/cflags/cflags.c
@@ -6,10 +6,10 @@
 
 int main(int argc, char *argv[])
 {
-#ifdef __OPTIMIZE__
-  printf("Using an optimization flag\n");
+#ifdef FOO
+  printf("FOO defined\n");
 #else
-  printf("Using no optimization flag\n");
+  printf("FOO not defined\n");
 #endif
   return 0;
 }
diff --git a/test/cflags/cflags.gyp b/test/cflags/cflags.gyp
index 76b2ea1..2840dc6 100644
--- a/test/cflags/cflags.gyp
+++ b/test/cflags/cflags.gyp
@@ -7,7 +7,6 @@
     {
       'target_name': 'cflags',
       'type': 'executable',
-      'opt': '-Os',
       'sources': [
         'cflags.c',
       ],
@@ -16,7 +15,6 @@
       'target_name': 'cflags_host',
       'toolsets': ['host'],
       'type': 'executable',
-      'opt': '-Os',
       'sources': [
         'cflags.c',
       ],
diff --git a/test/cflags/gyptest-cflags.py b/test/cflags/gyptest-cflags.py
index 21195ef..ff81eca 100755
--- a/test/cflags/gyptest-cflags.py
+++ b/test/cflags/gyptest-cflags.py
@@ -33,7 +33,7 @@
 
 try:
   PushEnv()
-  os.environ['CFLAGS'] = '-O0'
+  os.environ['CFLAGS'] = ''
   os.environ['GYP_CROSSCOMPILE'] = '1'
   test.run_gyp('cflags.gyp')
   test.build('cflags.gyp')
@@ -44,9 +44,7 @@
   PopEnv()
 
 
-expect = """\
-Using no optimization flag
-"""
+expect = """FOO not defined\n"""
 test.run_built_executable('cflags', stdout=expect)
 test.run_built_executable('cflags_host', stdout=expect)
 
@@ -54,7 +52,7 @@
 
 try:
   PushEnv()
-  os.environ['CFLAGS'] = '-O2'
+  os.environ['CFLAGS'] = '-DFOO=1'
   os.environ['GYP_CROSSCOMPILE'] = '1'
   test.run_gyp('cflags.gyp')
   test.build('cflags.gyp')
@@ -65,22 +63,18 @@
   PopEnv()
 
 
-expect = """\
-Using an optimization flag
-"""
+expect = """FOO defined\n"""
 test.run_built_executable('cflags', stdout=expect)
 
 # Environment variables shouldn't influence the flags for the host.
-expect = """\
-Using no optimization flag
-"""
+expect = """FOO not defined\n"""
 test.run_built_executable('cflags_host', stdout=expect)
 
 test.sleep()
 
 try:
   PushEnv()
-  os.environ['CFLAGS'] = '-O0'
+  os.environ['CFLAGS'] = ''
   test.run_gyp('cflags.gyp')
   test.build('cflags.gyp')
 finally:
@@ -90,16 +84,14 @@
   PopEnv()
 
 
-expect = """\
-Using no optimization flag
-"""
+expect = """FOO not defined\n"""
 test.run_built_executable('cflags', stdout=expect)
 
 test.sleep()
 
 try:
   PushEnv()
-  os.environ['CFLAGS'] = '-O2'
+  os.environ['CFLAGS'] = '-DFOO=1'
   test.run_gyp('cflags.gyp')
   test.build('cflags.gyp')
 finally:
@@ -109,9 +101,7 @@
   PopEnv()
 
 
-expect = """\
-Using an optimization flag
-"""
+expect = """FOO defined\n"""
 test.run_built_executable('cflags', stdout=expect)
 
 test.pass_test()